plugin_dir_url( __FILE__ ).'angularjs-templates/list-detail.html', 'single_detail' => plugin_dir_url( __FILE__ ).'angularjs-templates/single-detail.html', 'new_post' => plugin_dir_url( __FILE__ ).'angularjs-templates/new-post.html', 'post_content' => plugin_dir_url( __FILE__ ).'angularjs-templates/post-content.html', ); // TEMPLATE OVERRIDES if(file_exists(get_stylesheet_directory().'/angularjs-templates/list-detail.html')) { $template_directory['list_detail'] = get_stylesheet_directory_uri().'/angularjs-templates/list-detail.html'; } if(file_exists(get_stylesheet_directory().'/angularjs-templates/single-detail.html')) { $template_directory['single_detail'] = get_stylesheet_directory_uri().'/angularjs-templates/single-detail.html'; } if(file_exists(get_stylesheet_directory().'/angularjs-templates/new-post.html')) { $template_directory['new_post'] = get_stylesheet_directory_uri().'/angularjs-templates/new-post.html'; } if(file_exists(get_stylesheet_directory().'/angularjs-templates/post-content.html')) { $template_directory['post_content'] = get_stylesheet_directory_uri().'/angularjs-templates/post-content.html'; } $angularjs_for_wp_localize = array( 'site' => get_bloginfo('wpurl'), 'nonce' => wp_create_nonce( 'wp_rest' ), 'template_directory' => $template_directory ); if( function_exists( 'json_url' ) ) { $angularjs_for_wp_localize['base'] = json_url(); } if( function_exists( 'rest_get_url_prefix' ) ) { $angularjs_for_wp_localize['base'] = get_bloginfo( 'wpurl') . '/' . rest_get_url_prefix() . '/wp/v2'; } // Localize Variables wp_localize_script( 'angular-core', 'wpAngularVars', $angularjs_for_wp_localize ); } function post_add_tax_register() { $post_types = get_post_types( array( 'public' => true, 'exclude_from_search' => false ), 'names' ); foreach( $post_types as $cpt ) { if( $cpt === 'attachment' ) { continue; } register_api_field( $cpt, 'post_taxonomies', array( 'update_callback' => array( $this, 'post_add_tax' ), 'schema' => null, ) ); } } function post_add_tax( $value, $object, $field_name ) { //var_dump( $value ); foreach( $value as $term => $tax ){ wp_set_post_terms( $object->ID, array( intval( $term ) ), $tax, true ); } } } /** JSON REST API CHECK **/ function angularjs_plugin_dep() { if ( ! defined( 'REST_API_VERSION' ) ) { add_action( 'admin_notices', 'angular_wpapi_error' ); } } function angular_wpapi_error(){ echo '
JSON REST API must be installed and activated for the AngularJS for WP plugin to work properly - Install Plugin