最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

Issue passing action class to nested function. Admin Columns

programmeradmin0浏览0评论

Trying to run the same function for multiple actions. I've got it working for ACF, but the Admin Columns action has a class, and I think that's where I'm struggling, though I'm not sure.

//Works:
function acp_editing_saved_usage28( AC\Column $column, $post_id, $value ) {
    if ( get_post_type( $post_id ) == 'vbrands-products' ) {
        update_field( 'field_5ff7af3315c5b', 'hoop', $post_id);
    }
}

add_action( 'acp/editing/saved', 'acp_editing_saved_usage28', 10, 3 );

//Does not work, but should:
function testfunction(){
    if ( get_post_type( $post_id ) == 'vbrands-products' ) {
        update_field( 'field_5ff7af3315c5b', 'tedsssst', $post_id); 
    }   
}

function acp_editing_saved_usage28( AC\Column $column, $post_id, $value ) {
    testfunction();
}
add_action( 'acp/editing/saved', 'acp_editing_saved_usage28', 10, 3 );

//However, this does work with ACF and the following code using the same testfunction() from above:
function my_acf_save_post88( $post_id ) {
    testfunction();
}
add_action('acf/save_post', 'my_acf_save_post88');
发布评论

评论列表(0)

  1. 暂无评论