pageID = '1'; echo $_GET['post']; } // Getter/Setter for pageID function getPageID() { return $this->pageID; } function setPageID( $id ) { return $this->pageID = $id; } // Action hook: Wordpress 'init' function insertPages_init() { add_shortcode( 'insert', array( $this, 'insertPages_handleShortcode_insert' ) ); } // Action hook: Wordpress 'admin_init' function insertPages_admin_init() { // Add TinyMCE toolbar button filters only if current user has permissions if ( current_user_can( 'edit_posts' ) && current_user_can( 'edit_pages' ) && get_user_option( 'rich_editing' )=='true' ) { // Register the TinyMCE toolbar button script wp_enqueue_script( 'wpinsertpages', plugins_url( '/js/wpinsertpages.js', __FILE__ ), array( 'wpdialogs' ), '20140819' ); wp_localize_script( 'wpinsertpages', 'wpInsertPagesL10n', array( 'update' => __( 'Update' ), 'save' => __( 'Insert Page' ), 'noTitle' => __( '(no title)' ), 'noMatchesFound' => __( 'No matches found.' ), 'l10n_print_after' => 'try{convertEntities(wpLinkL10n);}catch(e){};', ) ); // Register the TinyMCE toolbar button styles wp_enqueue_style( 'wpinsertpagescss', plugins_url( '/css/wpinsertpages.css', __FILE__ ), array( 'wp-jquery-ui-dialog' ), '20140819' ); add_filter( 'mce_external_plugins', array( $this, 'insertPages_handleFilter_mceExternalPlugins' ) ); add_filter( 'mce_buttons', array( $this, 'insertPages_handleFilter_mceButtons' ) ); //load_plugin_textdomain('insert-pages', false, dirname(plugin_basename(__FILE__)).'/languages/'); } } // Shortcode hook: Replace the [insert ...] shortcode with the inserted page's content function insertPages_handleShortcode_insert( $atts, $content = null ) { global $wp_query, $post, $wp_current_filter; extract( shortcode_atts( array( 'page' => '0', 'display' => 'all', 'class' => '', ), $atts ) ); // Validation checks. if ( $page === '0' ) { return $content; } // Trying to embed same page in itself. if ( $page == $post->ID || $page == $post->post_name ) { return $content; } $should_apply_nesting_check = true; /** * Filter the flag indicating whether to apply deep nesting check * that can prevent circular loops. Note that some use cases rely * on inserting pages that themselves have inserted pages, so this * check should be disabled for those individuals. * * @param bool $apply_the_content_filter Indicates whether to apply the_content filter. */ $should_apply_nesting_check = apply_filters( 'insert_pages_apply_nesting_check', $should_apply_nesting_check ); // Don't allow inserted pages to be added to the_content more than once (prevent infinite loops). if ( $should_apply_nesting_check ) { $done = false; foreach ( $wp_current_filter as $filter ) { if ( 'the_content' == $filter ) { if ( $done ) { return $content; } else { $done = true; } } } } // Get page object from slug or id $temp_query = clone $wp_query; // we're starting a new loop within the main loop, so save the main query $temp_post = $wp_query->get_queried_object(); // see: http://codex.wordpress.org/The_Loop#Multiple_Loops_Example_2 // Convert slugs to page IDs to standardize query_posts() lookup below. if ( ! is_numeric( $page ) ) { $page_object = get_page_by_path( $page, OBJECT, get_post_types() ); $page = $page_object ? $page_object->ID : $page; } if ( is_numeric( $page ) ) { $args = array( 'p' => intval( $page ), 'post_type' => get_post_types(), ); } else { $args = array( 'name' => esc_attr( $page ), 'post_type' => get_post_types(), ); } query_posts( $args ); $should_apply_the_content_filter = true; /** * Filter the flag indicating whether to apply the_content filter to post * contents and excerpts that are being inserted. * * @param bool $apply_the_content_filter Indicates whether to apply the_content filter. */ $should_apply_the_content_filter = apply_filters( 'insert_pages_apply_the_content_filter', $should_apply_the_content_filter ); // Start our new Loop (only iterate once). if ( have_posts() ) { ob_start(); // Start output buffering so we can save the output to string // Show either the title, link, content, everything, or everything via a custom template // Note: if the sharing_display filter exists, it means Jetpack is installed and Sharing is enabled; // This plugin conflicts with Sharing, because Sharing assumes the_content and the_excerpt filters // are only getting called once. The fix here is to disable processing of filters on the_content in // the inserted page. @see https://codex.wordpress.org/Function_Reference/the_content#Alternative_Usage switch ( $display ) { case "title": the_post(); ?>