コード例 #1
1
 function init()
 {
     wpv_register_type_view_template();
     add_action('wp_ajax_set_view_template', array($this, 'ajax_action_callback'));
     add_filter('the_content', array($this, 'the_content'), 1, 1);
     add_filter('the_content', array($this, 'restore_wpautop'), 999, 1);
     add_filter('the_excerpt', array($this, 'the_excerpt_for_archives'), 1, 1);
     if (is_admin()) {
         global $pagenow;
         // Post/page language box
         if ($pagenow == 'post.php' || $pagenow == 'post-new.php') {
             add_action('admin_head', array($this, 'post_edit_template_options'));
             add_action('admin_head', array($this, 'post_edit_tinymce'));
             add_action('admin_footer', array($this, 'hide_view_template_author'));
             add_action('admin_notices', array($this, 'show_admin_messages'));
             // Post/page save actions
             add_action('save_post', array($this, 'save_post_actions'), 10, 2);
             add_filter('user_can_richedit', array($this, 'disable_rich_edit_for_views'));
         } elseif ($pagenow == 'admin-ajax.php') {
             // For when Types saves a child post
             add_action('save_post', array($this, 'save_post_actions'), 10, 2);
         }
         add_action('admin_head', array($this, 'include_admin_css'));
         add_action('wp_ajax_wpv_get_archive_view_template_taxonomy_summary', array($this, '_ajax_get_taxonomy_loop_summary'));
         add_action('wp_ajax_wpv_get_archive_view_template_post_type_summary', array($this, '_ajax_get_post_type_loop_summary'));
         add_action('wp_ajax_wpv_get_archive_view_template_post_type_edit', array($this, '_ajax_get_post_type_loop_edit'));
     } else {
         add_filter('edit_post_link', array($this, 'edit_post_link'), 10, 2);
         add_filter('body_class', array($this, 'body_class'), 10, 2);
         add_action('wp_footer', array($this, 'wpv_meta_html_extra'));
     }
     add_action('save_post', array($this, 'set_default_template'), 10, 2);
 }
コード例 #2
0
    function init(){

        wpv_register_type_view_template();
        add_action( 'wp_ajax_set_view_template', array( $this, 'set_view_template_callback' ) );
        add_filter( 'the_content', array( $this, 'the_content' ), 1, 1 );
        add_filter( 'the_content', array( $this, 'restore_wpautop' ), 999, 1 );
		
		/**
		 * Recreate the the_content filters, when doing a wpv-post-body shortcode with suppress_filters="true"
		 *
		 * @since 1.8.0
		 */
		
		if ( function_exists( 'WPV_wpcf_record_post_relationship_belongs' ) ) {
			add_filter( 'wpv_filter_wpv_the_content_suppressed', 'WPV_wpcf_record_post_relationship_belongs', 0, 1 );
		}
		add_filter( 'wpv_filter_wpv_the_content_suppressed', array( $this, 'the_content' ), 1, 1 );
		if ( isset( $GLOBALS['wp_embed'] ) ) {
			add_filter( 'wpv_filter_wpv_the_content_suppressed', array( $GLOBALS['wp_embed'], 'run_shortcode' ), 8 );
			add_filter( 'wpv_filter_wpv_the_content_suppressed', array( $GLOBALS['wp_embed'], 'autoembed' ), 8 );
		}
		add_filter( 'wpv_filter_wpv_the_content_suppressed', 'convert_smilies', 10 );
		add_filter( 'wpv_filter_wpv_the_content_suppressed', 'prepend_attachment', 10 );
		add_filter( 'wpv_filter_wpv_the_content_suppressed', 'capital_P_dangit', 11 );
		add_filter( 'wpv_filter_wpv_the_content_suppressed', 'do_shortcode', 11 );
		add_filter( 'wpv_filter_wpv_the_content_suppressed', array( $this, 'restore_wpautop' ), 999, 1 );

        add_filter('the_excerpt', array($this, 'the_excerpt_for_archives'), 1, 1);

        if(is_admin()){
            global $pagenow;

            // Post/page language box
            if($pagenow == 'post.php' || $pagenow == 'post-new.php'){
                add_action('admin_head', array($this,'post_edit_template_options'));

				// Post/page save actions
				add_action('save_post', array($this,'save_post_actions'), 10, 2);


            } elseif ($pagenow == 'admin-ajax.php') {
				// For when Types saves a child post
				add_action('save_post', array($this,'save_post_actions'), 10, 2);
			}

        } else {
            add_filter('body_class', array($this, 'body_class'), 10, 2);
            add_action('wp_footer', array($this, 'wpv_meta_html_extra_css'), 5); // Set priority lower than 20, so we load the CSS before the footer scripts and avoid the bottleneck
            add_action('wp_footer', array($this, 'wpv_meta_html_extra_js'), 25); // Set priority higher than 20, when all the footer scripts are loaded
        }

		add_action('add_attachment', array($this, 'set_template_for_attachments'), 10, 1);
		add_action('edit_attachment', array($this, 'set_template_for_attachments'), 10, 1);

		add_action('save_post', array($this, 'set_default_template'), 10, 2);

    }