| @@ -2,10 +2,10 @@ | ||
| 2 | 2 | |
| 3 | 3 | |
| 4 | 4 | namespace FilterEverything\Filter; |
| 5 | 5 | |
| 6 | -if ( ! defined('WPINC') ) { | |
| 7 | - wp_die(); | |
| 6 | +if ( ! defined('ABSPATH') ) { | |
| 7 | + exit; | |
| 8 | 8 | } |
| 9 | 9 | |
| 10 | 10 | class MetaBoxes |
| 11 | 11 | { |
| @@ -25,22 +25,22 @@ | ||
| 25 | 25 | 'high' |
| 26 | 26 | ); |
| 27 | 27 | |
| 28 | 28 | add_meta_box( |
| 29 | + 'filters-set-location', | |
| 30 | + esc_html__( "Location", 'filter-everything' ), | |
| 31 | + array( $this, 'locationMetabox' ), | |
| 32 | + FLRT_FILTERS_SET_POST_TYPE, | |
| 33 | + 'normal', | |
| 34 | + 'low' | |
| 35 | + ); | |
| 36 | + | |
| 37 | + add_meta_box( | |
| 29 | 38 | 'filters-set-settings', |
| 30 | 39 | esc_html__( "Settings", 'filter-everything' ), |
| 31 | 40 | array( $this, 'settingsMetabox' ), |
| 32 | 41 | FLRT_FILTERS_SET_POST_TYPE, |
| 33 | 42 | 'normal', |
| 34 | - 'high' | |
| 35 | - ); | |
| 36 | - | |
| 37 | - add_meta_box( | |
| 38 | - 'filters-set-notes', | |
| 39 | - esc_html__( "Popular Meta keys", 'filter-everything' ), | |
| 40 | - array( $this, 'notesMetabox' ), | |
| 41 | - FLRT_FILTERS_SET_POST_TYPE, | |
| 42 | - 'normal', | |
| 43 | 43 | 'low' |
| 44 | 44 | ); |
| 45 | 45 | |
| 46 | 46 | remove_meta_box( |
| @@ -56,11 +56,19 @@ | ||
| 56 | 56 | array( FLRT_FILTERS_SET_POST_TYPE ), |
| 57 | 57 | 'side' |
| 58 | 58 | ); |
| 59 | 59 | |
| 60 | + add_meta_box( | |
| 61 | + 'filter-set-advice', | |
| 62 | + esc_html__( 'How to?', 'filter-everything' ), | |
| 63 | + [ 'FilterEverything\Filter\MetaBoxes', 'adviceMetabox' ], | |
| 64 | + array( FLRT_FILTERS_SET_POST_TYPE ), | |
| 65 | + 'side' | |
| 66 | + ); | |
| 67 | + | |
| 60 | 68 | } |
| 61 | 69 | |
| 62 | - public function filtersMetabox( $post, $meta ) | |
| 70 | + public static function filtersMetabox( $post, $meta ) | |
| 63 | 71 | { |
| 64 | 72 | $args = array( |
| 65 | 73 | 'post' => $post, |
| 66 | 74 | 'meta' => $meta |
| @@ -69,9 +77,9 @@ | ||
| 69 | 77 | flrt_include_admin_view('filters-set', $args ); |
| 70 | 78 | |
| 71 | 79 | } |
| 72 | 80 | |
| 73 | - public function settingsMetabox( $post, $meta ){ | |
| 81 | + public static function settingsMetabox( $post, $meta ){ | |
| 74 | 82 | $args = array( |
| 75 | 83 | 'post' => $post, |
| 76 | 84 | 'meta' => $meta |
| 77 | 85 | ); |
| @@ -78,15 +86,24 @@ | ||
| 78 | 86 | |
| 79 | 87 | flrt_include_admin_view('filters-set-settings', $args ); |
| 80 | 88 | } |
| 81 | 89 | |
| 82 | - public function notesMetabox( $post, $meta ){ | |
| 90 | + public static function locationMetabox( $post, $meta ){ | |
| 83 | 91 | $args = array( |
| 92 | + 'post' => $post, | |
| 93 | + 'meta' => $meta | |
| 94 | + ); | |
| 95 | + | |
| 96 | + flrt_include_admin_view('filters-set-location', $args ); | |
| 97 | + } | |
| 98 | + | |
| 99 | + public static function adviceMetabox( $post, $meta ){ | |
| 100 | + $args = array( | |
| 84 | 101 | 'post' => $post, |
| 85 | 102 | 'meta' => $meta |
| 86 | 103 | ); |
| 87 | 104 | |
| 88 | - flrt_include_admin_view('filters-set-notes', $args ); | |
| 105 | + flrt_include_admin_view('filters-set-advices', $args ); | |
| 89 | 106 | } |
| 90 | 107 | |
| 91 | 108 | public static function commonSideMetaBox( $post, $args = array() ) { |
| 92 | 109 | global $action; |
| @@ -94,8 +111,10 @@ | ||
| 94 | 111 | $post_id = (int) $post->ID; |
| 95 | 112 | $post_type = $post->post_type; |
| 96 | 113 | $post_type_object = get_post_type_object( $post_type ); |
| 97 | 114 | $can_publish = current_user_can( $post_type_object->cap->publish_posts ); |
| 115 | + $filterSet = \FilterEverything\Filter\Container::instance()->getFilterSetService(); | |
| 116 | + $under_limit_filter_set = $filterSet->under_limit_filter_set($post_id); | |
| 98 | 117 | ?> |
| 99 | 118 | <div class="submitbox" id="submitpost"> |
| 100 | 119 | |
| 101 | 120 | <div id="minor-publishing"> |
| @@ -262,8 +281,34 @@ | ||
| 262 | 281 | * null on Edit Link screen. |
| 263 | 282 | */ |
| 264 | 283 | do_action( 'post_submitbox_start', $post ); |
| 265 | 284 | ?> |
| 285 | + <div class="duplicate-filter-set"> | |
| 286 | + <?php | |
| 287 | + $is_filter_set_post = ($post->post_type === FLRT_FILTERS_SET_POST_TYPE); | |
| 288 | + $can_duplicate = current_user_can('delete_post', $post->ID); | |
| 289 | + $is_pro_version = defined('FLRT_FILTERS_PRO') && FLRT_FILTERS_PRO; | |
| 290 | + | |
| 291 | + if ($is_filter_set_post && $can_duplicate) : | |
| 292 | + $label = esc_html__('Duplicate Filter Set', 'filter-everything'); | |
| 293 | + | |
| 294 | + if ($is_pro_version) : | |
| 295 | + $query_args = ['action' => 'flrt_duplicate_filter_set', 'post' => $post->ID]; | |
| 296 | + $base_url = add_query_arg($query_args, admin_url('admin.php')); | |
| 297 | + $url = wp_nonce_url($base_url, 'flrt_duplicate_filter_set'); | |
| 298 | + ?> | |
| 299 | + <a href="<?php echo esc_url($url); ?>"> | |
| 300 | + <span class="flrt-duplicate-filter-set">+</span> <?php echo $label; ?> | |
| 301 | + </a> | |
| 302 | + <?php else : ?> | |
| 303 | + <a href="<?php echo esc_url(flrt_vailable_in_pro_attr_link());?>" class="wpc-vailable-in-pro-link"> | |
| 304 | + <span class="flrt-duplicate-filter-set">+</span> | |
| 305 | + <?php echo $label; ?> | |
| 306 | + <?php echo '(' . esc_html__('PRO', 'filter-everything') . ')'; ?> | |
| 307 | + </a> | |
| 308 | + <?php endif; | |
| 309 | + endif; ?> | |
| 310 | + </div> | |
| 266 | 311 | <div id="delete-action"> |
| 267 | 312 | <?php |
| 268 | 313 | if ( current_user_can( 'delete_post', $post_id ) ) { |
| 269 | 314 | if ( ! EMPTY_TRASH_DAYS ) { |
| @@ -277,37 +322,52 @@ | ||
| 277 | 322 | } |
| 278 | 323 | ?> |
| 279 | 324 | </div> |
| 280 | 325 | |
| 281 | - <div id="publishing-action"> | |
| 326 | + <div id="publishing-action"<?php echo ($under_limit_filter_set) ? ' class="wpc_under_limit_filter_set_publish"' : ''; ?>> | |
| 282 | 327 | <span class="spinner"></span> |
| 283 | 328 | <?php |
| 329 | + $button_text = ''; | |
| 284 | 330 | if ( ! in_array( $post->post_status, array( 'publish', 'future', 'private' ), true ) || 0 === $post_id ) { |
| 285 | 331 | if ( $can_publish ) : |
| 286 | 332 | if ( ! empty( $post->post_date_gmt ) && time() < strtotime( $post->post_date_gmt . ' +0000' ) ) : |
| 287 | 333 | ?> |
| 288 | 334 | <input name="original_publish" type="hidden" id="original_publish" value="<?php echo esc_attr_x( 'Schedule', 'post action/button label' ); ?>" /> |
| 289 | - <?php submit_button( _x( 'Schedule', 'post action/button label' ), 'primary large', 'publish', false ); ?> | |
| 335 | + <?php | |
| 336 | + $button_text = _x( 'Schedule', 'post action/button label' ); | |
| 337 | + submit_button( $button_text, 'primary large', 'publish', false ); ?> | |
| 290 | 338 | <?php |
| 291 | 339 | else : |
| 292 | 340 | ?> |
| 293 | 341 | <input name="original_publish" type="hidden" id="original_publish" value="<?php esc_attr_e( 'Publish' ); ?>" /> |
| 294 | - <?php submit_button( esc_html__( 'Publish' ), 'primary large', 'publish', false ); ?> | |
| 342 | + <?php | |
| 343 | + $button_text = esc_html__( 'Publish' ); | |
| 344 | + submit_button( esc_html__( 'Publish' ), 'primary large', 'publish', false ); ?> | |
| 295 | 345 | <?php |
| 296 | 346 | endif; |
| 297 | 347 | else : |
| 298 | 348 | ?> |
| 299 | 349 | <input name="original_publish" type="hidden" id="original_publish" value="<?php esc_attr_e( 'Submit for Review' ); ?>" /> |
| 300 | - <?php submit_button( esc_html__( 'Submit for Review' ), 'primary large', 'publish', false ); ?> | |
| 350 | + <?php | |
| 351 | + $button_text = esc_html__( 'Submit for Review' ); | |
| 352 | + submit_button( esc_html__( 'Submit for Review' ), 'primary large', 'publish', false ); ?> | |
| 301 | 353 | <?php |
| 302 | 354 | endif; |
| 303 | 355 | } else { |
| 304 | 356 | ?> |
| 305 | 357 | <input name="original_publish" type="hidden" id="original_publish" value="<?php esc_attr_e( 'Update' ); ?>" /> |
| 306 | - <?php submit_button( esc_html__( 'Update' ), 'primary large', 'save', false, array( 'id' => 'publish' ) ); ?> | |
| 307 | 358 | <?php |
| 359 | + $button_text = esc_html__( 'Update' ); | |
| 360 | + submit_button( esc_html__( 'Update' ), 'primary large', 'save', false, array( 'id' => 'publish' ) ); ?> | |
| 361 | + <?php | |
| 308 | 362 | } |
| 309 | 363 | ?> |
| 364 | + <?php | |
| 365 | + if(!defined('FLRT_FILTERS_PRO')){ | |
| 366 | + if ( $under_limit_filter_set ) { | |
| 367 | + echo flrt_unlock_in_pro($button_text); | |
| 368 | + } | |
| 369 | + } ?> | |
| 310 | 370 | </div> |
| 311 | 371 | <div class="clear"></div> |
| 312 | 372 | </div> |
| 313 | 373 | |