示例#1
0
 /**
  * Load the checkbox on the side publish area to enable / disable single view option.
  *
  * @return void
  */
 public function load_checkbox()
 {
     // Bail if we aren't on a supported type.
     if (false === ($types = RKV_SVO_Helper::check_post_types())) {
         return;
     }
     // Only fire if user has the option.
     if (!current_user_can('edit_posts')) {
         return;
     }
     // Check for the auto-enable.
     if (false !== ($auto = RKV_SVO_Helper::check_auto_enable())) {
         // Output the box.
         echo '<div id="single-view" class="misc-pub-section misc-pub-single-view">';
         echo '<p class="description">' . esc_html__('The single view option is auto enabled.', 'single-view-option') . '</p>';
         echo '</div>';
         // And return.
         return;
     }
     // Fetch my global post object.
     global $post;
     // Bail without a post object or type, or not in our allowed types.
     if (!is_object($post) || empty($post->post_type) || !in_array($post->post_type, RKV_SVO_Helper::get_post_types())) {
         return;
     }
     // Fetch the meta value itself.
     $single = get_post_meta($post->ID, '_svo_active', true);
     // Use nonce for verification.
     wp_nonce_field('svo_meta_nonce', 'svo_meta_nonce');
     // Echo our the actual side checkbox.
     echo '<div id="single-view" class="misc-pub-section misc-pub-single-view">';
     echo '<label for="svo-active">';
     echo '<input type="checkbox" name="svo-active" id="svo-active" value="1" ' . checked($single, 1, false) . '>';
     echo ' ' . esc_html__('Enable the single view option.', 'single-view-option') . '</label>';
     echo '</div>';
 }
示例#2
0
 /**
  * Remove the paginated output if requested.
  *
  * @param  array $args  The original pagination args.
  *
  * @return array $args  The updated pagination args.
  */
 public function link_args($args)
 {
     // Bail if we aren't on a supported type.
     if (false === ($types = RKV_SVO_Helper::check_post_types())) {
         return $args;
     }
     // Call the $wp_query global.
     global $wp_query;
     // Check the content for the `nextpage` tag.
     if (false === ($tag = RKV_SVO_Helper::check_post_content($wp_query->post->ID))) {
         return $args;
     }
     // If we have not activated it, return the original content.
     if (!isset($wp_query->query['all']) || false === ($check = RKV_SVO_Helper::check_post_active($wp_query->post->ID))) {
         return $args;
     }
     // Set the 'echo' arg to false.
     $args['echo'] = 0;
     // Return our array of args.
     return $args;
 }