function et_pb_layout_restrict_manage_posts()
{
    global $pagenow;
    if (!is_admin() || 'edit.php' !== $pagenow || !isset($_GET['post_type']) || 'et_pb_layout' !== $_GET['post_type']) {
        return;
    }
    $used_built_for_post_types = et_pb_get_used_built_for_post_types();
    if (count($used_built_for_post_types) <= 1) {
        return;
    }
    $built_for_post_type_request = isset($_GET['built_for']) ? sanitize_text_field($_GET['built_for']) : '';
    if (!in_array($built_for_post_type_request, $used_built_for_post_types)) {
        $built_for_post_type_request = '';
    }
    ?>
	<select name="built_for">
		<option><?php 
    esc_html_e('Built For Any', 'et_builder');
    ?>
</option>
		<?php 
    $is_default_added = false;
    ?>
		<?php 
    foreach ($used_built_for_post_types as $built_for_post_type) {
        ?>
		<?php 
        $is_default_post_type = in_array($built_for_post_type, et_pb_get_standard_post_types());
        // do not add default post types into the menu if it was added already
        if ($is_default_post_type && $is_default_added) {
            continue;
        }
        ?>
			<?php 
        $built_for_post_type_display = apply_filters('et_pb_built_for_post_type_display', $built_for_post_type);
        ?>
			<option value="<?php 
        echo esc_attr($built_for_post_type);
        ?>
" <?php 
        selected($built_for_post_type_request, $built_for_post_type);
        ?>
><?php 
        echo esc_html(ucwords($built_for_post_type_display));
        ?>
</option>
		<?php 
        $is_default_added = $is_default_post_type ? true : $is_default_added;
    }
    ?>
	</select>
	<?php 
}
示例#2
0
function et_pb_layout_restrict_manage_posts()
{
    global $pagenow;
    if (!is_admin() || 'edit.php' !== $pagenow || !isset($_GET['post_type']) || 'et_pb_layout' !== $_GET['post_type']) {
        return;
    }
    $used_built_for_post_types = et_pb_get_used_built_for_post_types();
    if (count($used_built_for_post_types) <= 1) {
        return;
    }
    $built_for_post_type_request = isset($_GET['built_for']) ? sanitize_text_field($_GET['built_for']) : '';
    if (!in_array($built_for_post_type_request, $used_built_for_post_types)) {
        $built_for_post_type_request = '';
    }
    ?>
	<select name="built_for">
		<option><?php 
    esc_html_e('Built For Any', 'et_builder');
    ?>
</option>
		<?php 
    foreach ($used_built_for_post_types as $built_for_post_type) {
        ?>
		<?php 
        $built_for_post_type_display = apply_filters('et_pb_built_for_post_type_display', $built_for_post_type);
        ?>
		<option value="<?php 
        echo esc_attr($built_for_post_type);
        ?>
" <?php 
        selected($built_for_post_type_request, $built_for_post_type);
        ?>
><?php 
        echo esc_html(ucwords($built_for_post_type_display));
        ?>
</option>
		<?php 
    }
    ?>
	</select>
	<?php 
}
示例#3
0
文件: functions.php 项目: smoobs/gft
 function exclude_premade_layouts_library($query)
 {
     global $pagenow;
     $current_post_type = get_query_var('post_type');
     if (is_admin() && 'edit.php' === $pagenow && $current_post_type && 'et_pb_layout' === $current_post_type) {
         $meta_query = array(array('key' => '_et_pb_predefined_layout', 'value' => 'on', 'compare' => 'NOT EXISTS'));
         $used_built_for_post_types = et_pb_get_used_built_for_post_types();
         if (isset($_GET['built_for']) && count($used_built_for_post_types) > 1) {
             $built_for_post_type = sanitize_text_field($_GET['built_for']);
             // get array of all standard post types if built_for is one of them
             $built_for_post_type_processed = in_array($built_for_post_type, et_pb_get_standard_post_types()) ? et_pb_get_standard_post_types() : $built_for_post_type;
             if (in_array($built_for_post_type, $used_built_for_post_types)) {
                 $meta_query[] = array('key' => '_et_pb_built_for_post_type', 'value' => $built_for_post_type_processed, 'compare' => 'IN');
             }
         }
         $query->set('meta_query', $meta_query);
     }
     return $query;
 }