Plugin Directory

Changeset 2441390


Ignore:
Timestamp:
12/17/2020 10:39:49 AM (5 years ago)
Author:
devbunch
Message:

mega menu change

Location:
master-elements/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • master-elements/trunk/masterelements.php

    r2421516 r2441390  
    1010 * Plugin URI: https://akdesigner.com/
    1111 * Author: TeamDevBunch
    12  * Version: 7.5
     12 * Version: 7.6
    1313 * Tested up to: 5.5
    1414 * Author URI: https://devbunch.com/
  • master-elements/trunk/modules/theme-builder/me-cpt.php

    r2427296 r2441390  
    11<?php
    22
     3
     4
    35namespace MasterElements\Modules\Theme_Builder;
    46
     7
     8
    59use Elementor\Widgets_Manager;
     10
    611use MasterElements;
     12
    713use MasterElements\Modules\Manager\Api;
    814
     15
     16
    917defined('ABSPATH') || exit;
    1018
    1119
     20
     21
     22
    1223$p_count = '1';
    1324
     25
     26
    1427class Master_Custom_Post
     28
    1529{
    1630
    1731
     32
     33
     34
    1835    public function __construct()
     36
    1937    {
    2038
     39
     40
    2141        $this->create_table();
    2242
     43
     44
    2345        $this->post_type();
    2446
    2547
     48
     49
     50
    2651        if (is_admin()) {
     52
    2753            $par = [
     54
    2855                "me_header_settings",
     56
    2957                "me_footer_settings",
     58
    3059                "me_archive_settings",
     60
    3161                "me_single_settings",
     62
    3263                "me_404_settings",
     64
    3365                "me_blog_settings",
     66
    3467                "me_maintenance_settings",
     68
    3569                "me_section_settings",
     70
    3671                "me_search_settings",
     72
    3773                "me_comingsoon_settings",
     74
    3875                "me_megamenu_settings",
     76
    3977                "me_wooproduct_settings"
     78
    4079            ];
    4180
     81
     82
    4283            if (in_array(isset($_GET['page']), $par)) {
     84
    4385                wp_enqueue_style('modal-css', 'https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css', false, \MasterElements::version);
     86
    4487                wp_enqueue_script('modal-js', 'https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js', array('jquery'), \MasterElements::version, true);
     88
    4589            }
    4690
     91
     92
    4793        }
    4894
    4995
     96
     97
     98
    5099        // wp_enqueue_script('modal-js', 'https://cdnjs.cloudflare.com/ajax/libs/jquery/3.0.0/jquery.min.js', array( 'jquery' ), \MasterElements::version, true );
    51100
    52101
     102
     103
     104
    53105        add_action('wp_ajax_save_me_settings', [$this, 'save_me_settings']);
    54106
     107
     108
    55109        add_action('wp_ajax_nopriv_save_me_settings', [$this, 'save_me_settings']);
    56110
     111
     112
    57113        add_action('wp_ajax_remove_post_meta_condition', [$this, 'remove_post_meta_condition']);
    58114
     115
     116
    59117        add_action('wp_ajax_nopriv_remove_post_meta_condition', [$this, 'remove_post_meta_condition']);
    60118
     119
     120
    61121        add_action('wp_ajax_open_edit_modal', [$this, 'open_edit_modal']);
    62122
     123
     124
    63125        add_action('wp_ajax_nopriv_open_edit_modal', [$this, 'open_edit_modal']);
    64126
     127
     128
    65129        add_action('wp_ajax_update_post_type_condition', [$this, 'update_post_type_condition']);
    66130
     131
     132
    67133        add_action('wp_ajax_nopriv_update_post_type_condition', [$this, 'update_post_type_condition']);
    68134
     135
     136
    69137        add_action('wp_ajax_activation_updated', [$this, 'activation_updated']);
    70138
     139
     140
    71141        add_action('wp_ajax_nopriv_activation_updated', [$this, 'activation_updated']);
    72142
     143
     144
    73145        add_action('admin_menu', [$this, 'cpt_menu']);
    74146
     147
     148
    75149        add_filter('single_template', [$this, 'load_canvas_template']);
    76150
     151
     152
    77153        add_filter('manage_me_footer_posts_columns', [$this, 'add_new_columns']);
    78154
     155
     156
    79157        add_action('manage_me_footer_posts_custom_column', [$this, 'custom_column_data']);
    80158
     159
     160
    81161        add_filter('manage_me_header_posts_columns', [$this, 'add_new_columns']);
    82162
     163
     164
    83165        add_action('manage_me_header_posts_custom_column', [$this, 'custom_column_data']);
    84166
     167
     168
    85169        add_filter('manage_me_archive_posts_columns', [$this, 'add_new_columns']);
    86170
     171
     172
    87173        add_action('manage_me_archive_posts_custom_column', [$this, 'custom_column_data']);
    88174
     175
     176
    89177        add_filter('manage_me_single_posts_columns', [$this, 'add_new_columns']);
    90178
     179
     180
    91181        add_action('manage_me_single_posts_custom_column', [$this, 'custom_column_data']);
    92182
     183
     184
    93185        add_filter('manage_me_wooproduct_posts_columns', [$this, 'add_new_columns']);
    94186
     187
     188
    95189        add_action('manage_me_wooproduct_posts_custom_column', [$this, 'custom_column_data']);
    96190
     191
     192
    97193        add_filter('manage_me_404_posts_columns', [$this, 'add_new_columns']);
    98194
     195
     196
    99197        add_action('manage_me_404_posts_custom_column', [$this, 'custom_column_data']);
    100198
     199
     200
    101201        add_filter('manage_me_blog_posts_columns', [$this, 'add_new_columns']);
    102202
     203
     204
    103205        add_action('manage_me_blog_posts_custom_column', [$this, 'custom_column_data']);
    104206
     207
     208
    105209        add_filter('manage_me_maintenance_posts_columns', [$this, 'add_new_columns']);
    106210
     211
     212
    107213        add_action('manage_me_maintenance_posts_custom_column', [$this, 'custom_column_data']);
    108214
     215
     216
    109217        add_filter('manage_me_section_posts_columns', [$this, 'add_new_columns']);
    110218
     219
     220
    111221        add_action('manage_me_section_posts_custom_column', [$this, 'custom_column_data']);
    112222
     223
     224
    113225        add_filter('manage_me_search_posts_columns', [$this, 'add_new_columns']);
    114226
     227
     228
    115229        add_action('manage_me_search_posts_custom_column', [$this, 'custom_column_data']);
    116230
     231
     232
    117233        add_action('wp_ajax_check_module_active', [$this, 'check_module_active']);
    118234
     235
     236
    119237        add_action('wp_ajax_get_menu_template', [$this, 'get_menu_template']);
    120238
     239
     240
    121241        add_action('wp_ajax_save_menu_postmeta', [$this, 'save_menu_postmeta']);
    122242
     243
     244
    123245        add_action('wp_ajax_get_megamenu_control', [$this, 'get_megamenu_control']);
    124246
     247
     248
    125249        add_action('wp_ajax_demo_data_import', [$this, 'demo_data_import']);
    126250
     251
     252
    127253        add_action('wp_ajax_send_feedback', [$this, 'send_feedback']);
    128254
     255
     256
    129257        add_action('wp_ajax_get_cat_data', [$this, 'get_cat_data']);
    130258
    131259
     260
     261
     262
    132263        wp_enqueue_script('forms-js', \MasterElements::widgets_url() . '/me-forms/assets/js/forms.js', false, \MasterElements::version);
    133264
     265
     266
    134267        wp_localize_script('forms-js', 'MS_Ajax', array(
     268
    135269            'ajaxurl' => admin_url('admin-ajax.php'),
     270
    136271        ));
     272
    137273        add_action('wp_ajax_custom_submit_form', [$this, 'custom_submit_form']);
     274
    138275        add_action('wp_ajax_nopriv_custom_submit_form', [$this, 'custom_submit_form']);
    139276
     277
     278
    140279    }
    141280
     281
     282
    142283    function post_type()
     284
    143285    {
    144286
    145287
     288
     289
     290
    146291        $template_types = $this->register_sections();
    147292
     293
     294
    148295        $settings = $this->get_main_settings_data();
    149296
     297
     298
    150299        foreach ($template_types as $type) {
    151300
     301
     302
    152303            if (isset($settings[$type['id']]['name']) && $settings[$type['id']]['name'] = $type['id'] && $settings[$type['id']]['value'] != 'no') {
    153304
    154305
     306
     307
     308
    155309                $labels = array(
    156310
     311
     312
    157313                    'name' => __($type['name'], 'masterelements'),
    158314
     315
     316
    159317                    'singular_name' => __($type['single'], 'masterelements'),
    160318
     319
     320
    161321                    'menu_name' => __($type['name'], 'masterelements'),
    162322
     323
     324
    163325                    'name_admin_bar' => __($type['name'], 'masterelements'),
    164326
     327
     328
    165329                    'add_new' => __('Add New', 'masterelements'),
    166330
     331
     332
    167333                    'add_new_item' => __('Add New ' . $type['item'], 'masterelements'),
    168334
     335
     336
    169337                    'new_item' => __('New ' . $type['item'], 'masterelements'),
    170338
     339
     340
    171341                    'edit_item' => __('Edit ' . $type['item'], 'masterelements'),
    172342
     343
     344
    173345                    'view_item' => __('View ' . $type['item'], 'masterelements'),
    174346
     347
     348
    175349                    'all_items' => __('All ' . $type['item'], 'masterelements'),
    176350
     351
     352
    177353                    'search_items' => __('Search ' . $type['item'], 'masterelements'),
    178354
     355
     356
    179357                    'parent_item_colon' => __('Parent ' . $type['item'], 'masterelements'),
    180358
     359
     360
    181361                    'not_found' => __('No ' . $type['item'] . ' found.', 'masterelements'),
    182362
     363
     364
    183365                    'not_found_in_trash' => __('No ' . $type['item'] . ' found in Trash.', 'masterelements'),
    184366
     367
     368
    185369                );
    186370
     371
     372
    187373                $args = array(
    188374
     375
     376
    189377                    'labels' => $labels,
    190378
     379
     380
    191381                    'public' => true,
    192382
     383
     384
    193385                    'menu_icon' => __((isset($type['icon']) ? $type['icon'] : 'dashicons-cart'), 'masterelements'),
    194386
     387
     388
    195389                    'rewrite' => false,
    196390
     391
     392
    197393                    'show_ui' => true,
    198394
     395
     396
    199397                    'show_in_menu' => true,
    200398
     399
     400
    201401                    'show_in_nav_menus' => true,
    202402
     403
     404
    203405                    'exclude_from_search' => true,
    204406
     407
     408
    205409                    'capability_type' => 'page',
    206410
     411
     412
    207413                    'hierarchical' => false,
    208414
     415
     416
    209417                    'supports' => array('title', 'elementor'),
    210418
     419
     420
    211421                );
    212422
    213423
     424
     425
     426
    214427                register_post_type($type['id'], $args);
    215428
     429
     430
    216431            }
    217432
     433
     434
    218435        }
    219436
     437
     438
    220439    }
    221440
    222441
     442
     443
     444
    223445    function open_edit_modal()
    224446
     447
     448
    225449    {
    226450
     451
     452
    227453        if (!empty($_GET['meta_ids']) && !empty($_GET['meta_types'])) {
    228454
     455
     456
    229457            $meta_ids = explode(',', $_GET['meta_ids']);
    230458
     459
     460
    231461            $condition_a = self::get_complete_meta($meta_ids[0]);
    232462
     463
     464
    233465            $condition_sindular = self::get_complete_meta($meta_ids[1]);
    234466
     467
     468
    235469            $condition_singular_id = self::get_complete_meta($meta_ids[2]);
    236470
     471
     472
    237473            $selected_a = '';
    238474
     475
     476
    239477            $selected_b = '';
    240478
     479
     480
    241481            $data['condition_a'] = '';
    242482
     483
     484
    243485            $data['condition_sing'] = '';
    244486
     487
     488
    245489            $data['condition_singular_id'] = '';
    246490
     491
     492
    247493            $condition_a_meta_val = $condition_a[0]->meta_value;
    248494
     495
     496
    249497            $consition_sing_meta_val = $condition_sindular[0]->meta_value;
    250498
     499
     500
    251501            $condition_sing_id_meta_val = $condition_singular_id[0]->meta_value;
    252502
     503
     504
    253505            // $postids = unserialize($condition_sing_id_meta_val);
    254506
     507
     508
    255509            // print_r($postids);
    256510
     511
     512
    257513            // exit();
    258514
     515
     516
    259517            $data['condition_a_meta_value'] = $condition_a_meta_val;
    260518
     519
     520
    261521            $data['consition_sing_meta_val'] = $consition_sing_meta_val;
    262522
     523
     524
    263525            $data['condition_sing_id_meta_val'] = $condition_sing_id_meta_val;
    264526
    265527
     528
     529
     530
    266531            $data['condition_a'] = '<option value="entire_site" ' . $selected_a = ($condition_a_meta_val === "entire_site" ? "selected='selected'" : "") . '>' . __("Entire Site", "masterelements") . '</option> <option value="singular" ' . $selected_a = ($condition_a_meta_val === "singular" ? "selected='selected'" : "") . '>' . __("Singular", "masterelements") . '</option>
    267532
     533
     534
    268535                <option value="archive" ' . $selected_a = ($condition_a_meta_val === "archive" ? "selected='selected'" : "") . '>' . __("Archive", "masterelements") . '</option>
    269536
    270537
     538
     539
     540
    271541            <option value="archive" ' . $selected_a = ($condition_a_meta_val === "archive" ? "selected='selected'" : "") . '>' . __("Archive", "masterelements") . '</option>
    272542
     543
     544
    273545                <option value="woo_single_product" ' . $selected_a = ($condition_a_meta_val === "woo_single_product" ? "selected='selected'" : "") . '>' . __("MW: Single Product", "masterelements") . '</option>
    274546
     547
     548
    275549                <option value="woo_archive_product" ' . $selected_a = ($condition_a_meta_val === "woo_archive_product" ? "selected='selected'" : "") . '>' . __("MW: Archive Product", "masterelements") . '</option>
    276550
     551
     552
    277553                <option value="woo_product_cart" ' . $selected_a = ($condition_a_meta_val === "woo_product_cart" ? "selected='selected'" : "") . '>' . __("MW: Product Cart", "masterelements") . '</option>
    278554
     555
     556
    279557                <option value="woo_product_checkout" ' . $selected_a = ($condition_a_meta_val === "woo_product_checkout" ? "selected='selected'" : "") . '>' . __("MW: Product Checkout", "masterelements") . '</option>
     558
    280559               
     560
    281561                <option value="woo_my_account" ' . $selected_a = ($condition_a_meta_val === "woo_my_account" ? "selected='selected'" : "") . '>' . __("MW: My Account Page", "masterelements") . '</option>
     562
    282563           
     564
    283565                <option value="woo_thankyou_page" ' . $selected_a = ($condition_a_meta_val === "woo_thankyou_page" ? "selected='selected'" : "") . '>' . __("MW: Thankyou Page", "masterelements") . '</option>';
    284566
     567
     568
    285569            $data['condition_sing'] = ' <option value="">' . __('Select Any', 'masterelements') . '</option>
    286570
     571
     572
    287573                <option value="all" ' . $selected_b = ($consition_sing_meta_val === "all" ? "selected='selected'" : "") . '>' . __('All Singulars', 'masterelements') . '</option>
    288574
     575
     576
    289577                <option value="front_page" ' . $selected_b = ($consition_sing_meta_val === "front_page" ? "selected='selected'" : "") . '>' . __('Front Page', 'masterelements') . '</option>
    290578
     579
     580
    291581                <option value="all_posts"  ' . $selected_b = ($consition_sing_meta_val === "all_posts" ? "selected='selected'" : "") . '>' . __('All Posts', 'masterelements') . '</option>
    292582
     583
     584
    293585                <option value="all_pages"  ' . $selected_b = ($consition_sing_meta_val === "all_pages" ? "selected='selected'" : "") . '>' . __('All Pages', 'masterelements') . '</option>
    294586
     587
     588
    295589                <option value="404page"  ' . $selected_b = ($consition_sing_meta_val === "404page" ? "selected='selected'" : "") . '>' . __('404 Page', 'masterelements') . '</option>
    296590
     591
     592
    297593                <option value="selective"  ' . $selected_b = ($consition_sing_meta_val === "selective" ? "selected='selected'" : "") . '>' . __('Selective Singular', 'masterelements') . '</option>';
    298594
    299595
     596
     597
     598
    300599            $data['condition_singular_id'] = '';
    301600
     601
     602
    302603            $postids = array();
    303604
     605
     606
    304607            if (!empty($condition_sing_id_meta_val)) {
    305608
     609
     610
    306611                $postids = unserialize($condition_sing_id_meta_val);
    307612
     613
     614
    308615            }
    309616
     617
     618
    310619            $args = array(
    311620
     621
     622
    312623                'public' => true,
    313624
     625
     626
    314627            );
    315628
    316629
     630
     631
     632
    317633            $output = 'names'; // 'names' or 'objects' (default: 'names')
    318634
     635
     636
    319637            $operator = 'and'; // 'and' or 'or' (default: 'and')
    320638
    321639
     640
     641
     642
    322643            $post_types = get_post_types($args, $output, $operator);
    323644
    324645
     646
     647
     648
    325649            if ($post_types) { // If there are any custom public post types.
    326650
     651
     652
    327653                foreach ($post_types as $post_type) {
    328654
     655
     656
    329657                    $args = array(
    330658
     659
     660
    331661                        'numberposts' => -1,
    332662
     663
     664
    333665                        'post_type' => $post_type
    334666
     667
     668
    335669                    );
    336670
     671
     672
    337673                    $ecpt = array('metemplate', 'elementor_library', 'attachment');
    338674
     675
     676
    339677                    if (!in_array($post_type, $ecpt)) {
    340678
     679
     680
    341681                        $posts = get_posts($args);
    342682
     683
     684
    343685                        if ($posts) {
    344686
     687
     688
    345689                            foreach ($posts as $post) :
    346690
     691
     692
    347693                                setup_postdata($post);
    348694
     695
     696
    349697                                $selected = '';
    350698
     699
     700
    351701                                if (in_array($post->ID, $postids)) {
    352702
     703
     704
    353705                                    $selected = "selected";
    354706
     707
     708
    355709                                }
    356710
     711
     712
    357713                                $data['condition_singular_id'] .= '<option value="' . $post->ID . '" ' . $selected . ' >' . $post->post_title . '</option>';
    358714
     715
     716
    359717                            endforeach;
    360718
     719
     720
    361721                            wp_reset_postdata();
    362722
     723
     724
    363725                        }
    364726
     727
     728
    365729                    }
    366730
     731
     732
    367733                }
    368734
     735
     736
    369737            }
    370738
     739
     740
    371741            print_r(json_encode($data, true));
    372742
     743
     744
    373745            wp_die();
    374746
     747
     748
    375749        }
    376750
    377751
     752
     753
     754
    378755    }
    379756
     757
     758
    380759    function update_post_type_condition()
    381760
     761
     762
    382763    {
    383764
     765
     766
    384767        print_r($_GET['condition_singular_id']);
    385768
     769
     770
    386771        // exit();
    387772
     773
     774
    388775        if (!empty($_GET['meta_ids'])) {
    389776
    390777
     778
     779
     780
    391781            $meta_ids = explode(',', $_GET['meta_ids']);
    392782
     783
     784
    393785            $condition_a = self::get_complete_meta($meta_ids[0]);
    394786
     787
     788
    395789            $condition_sindular = self::get_complete_meta($meta_ids[1]);
    396790
     791
     792
    397793            $condition_singular_id = self::get_complete_meta($meta_ids[2]);
    398794
     795
     796
    399797            if (isset($_GET['condition_a']) && !empty($_GET['condition_a'])) {
    400798
     799
     800
    401801                update_post_meta($condition_a[0]->post_id, $condition_a[0]->meta_key, $_GET['condition_a']);
    402802
     803
     804
    403805            }
    404806
     807
     808
    405809            if (isset($_GET['condition_singular'])) {
    406810
     811
     812
    407813                update_post_meta($condition_sindular[0]->post_id, $condition_sindular[0]->meta_key, $_GET['condition_singular']);
    408814
     815
     816
    409817            }
    410818
     819
     820
    411821            if (isset($_GET['condition_singular_id'])) {
    412822
     823
     824
    413825                update_post_meta($condition_singular_id[0]->post_id, $condition_singular_id[0]->meta_key, $_GET['condition_singular_id']);
    414826
     827
     828
    415829            }
    416830
     831
     832
    417833            echo json_encode(array('status' => 'success', 'msg' => 'Settings Updated'));
    418834
     835
     836
    419837            // echo "here";
    420838
     839
     840
    421841            wp_die();
    422842
     843
     844
    423845        }
    424846
     847
     848
    425849    }
    426850
     851
     852
    427853    function cpt_menu()
     854
    428855    {
    429856
     857
     858
    430859        $template_types = $this->register_sections();
    431860
     861
     862
    432863        $settings = $this->get_main_settings_data();
    433864
     865
     866
    434867        add_submenu_page('masterelements', esc_html__('Dashboard', 'masterelements'), esc_html__('Dashboard', 'masterelements'), 'manage_options', 'masterelements', [$this, 'dashboard']);
    435868
     869
     870
    436871        add_submenu_page('masterelements', esc_html__('Options', 'masterelements'), esc_html__('Options', 'masterelements'), 'manage_options', 'settings', [$this, 'me_settings']);
    437872
    438873
     874
     875
     876
    439877        foreach ($template_types as $type) {
    440878
     879
     880
    441881            if (isset($settings[$type['id']]['name']) && $settings[$type['id']]['name'] = $type['id'] && $settings[$type['id']]['value'] != 'no') {
    442882
     883
     884
    443885                add_submenu_page(
    444886
     887
     888
    445889                    'edit.php?post_type=' . $type['id'],
    446890
     891
     892
    447893                    __('Settings', 'masterelements'),
    448894
     895
     896
    449897                    __('Settings', 'masterelements'),
    450898
     899
     900
    451901                    'manage_options',
    452902
     903
     904
    453905                    $type['id'] . '_settings',
    454906
     907
     908
    455909                    [$this, 'posttypes_settings']);
    456910
    457911
     912
     913
     914
    458915            }
    459916
     917
     918
    460919        }
    461920
     921
     922
    462923    }
    463924
    464925
     926
     927
     928
    465929    function me_settings()
     930
    466931    {
    467932
     933
     934
    468935        require_once \MasterElements:: plugin_dir() . 'admin/pages/settings.php';
    469936
     937
     938
    470939    }
    471940
    472941
     942
     943
     944
    473945    function posttypes_settings()
     946
    474947    {
    475948
     949
     950
    476951        $activation = 'no';
    477952
     953
     954
    478955        $condition_a = '';
    479956
     957
     958
    480959        $condition_singular = '';
    481960
     961
     962
    482963        ?>
    483964
    484965
     966
     967
     968
    485969        <form action="" method="POST">
    486970
     971
     972
    487973            <div class="em-outer-box">
    488974
     975
     976
    489977                <div class="em-option-boxes activation-box">
    490978
    491979
     980
     981
     982
    492983                    <div class="activation-container-box">
    493984
     985
     986
    494987                        <label class="attr-input-label"><?php esc_html_e('Activition:', 'masterelements'); ?></label>
    495988
     989
     990
    496991                        <div class="master-admin-input-switch">
    497992
     993
     994
    498995                            <input type="checkbox" value="<?= $activation; ?>"
     996
    499997                                   class="master-admin-control-input master-template-activition master-active-<?= $activation; ?>"
     998
    500999                                   name="activation_val" id="master_activation_input">
    5011000
     1001
     1002
    5021003                            <label class="master-admin-control-label" for="master_activation_modal_input">
    5031004
     1005
     1006
    5041007                                                    <span class="master-admin-control-label-switch" data-active="ON"
    5051008
     1009
     1010
    5061011                                                          data-inactive="OFF"></span>
    5071012
     1013
     1014
    5081015                            </label>
    5091016
     1017
     1018
    5101019                            <input type="hidden" class="activation_filed" id="activation_filed" name="activation"
     1020
    5111021                                   value="">
    5121022
     1023
     1024
    5131025                        </div>
    5141026
     1027
     1028
    5151029                    </div>
    5161030
    5171031
     1032
     1033
     1034
    5181035                    <div class="activation-container-box">
    5191036
     1037
     1038
    5201039                        <div class="activation-flex-box">
    5211040
     1041
     1042
    5221043                            <label class="attr-input-label"><?php esc_html_e('Choose Template:', 'masterelements'); ?></label>
    5231044
     1045
     1046
    5241047                        </div>
    5251048
     1049
     1050
    5261051                        <div class="activation-flex-box">
    5271052
     1053
     1054
    5281055                            <div class="selection-box">
    5291056
     1057
     1058
    5301059                                <h4>
     1060
    5311061                                    <label class="attr-input-label"><?php esc_html_e('Select One:', 'masterelements'); ?></label>
     1062
    5321063                                </h4>
    5331064
     1065
     1066
    5341067                                <select id="header-selection" name="type"
     1068
    5351069                                        class="master-template-type attr-form-control select2 header-selection-dropdown">
    5361070
     1071
     1072
    5371073                                    <?php
    5381074
     1075
     1076
    5391077                                    $args = array(
    5401078
     1079
     1080
    5411081                                        'numberposts' => -1,
    5421082
     1083
     1084
    5431085                                        'post_type' => $_GET['post_type']
    5441086
     1087
     1088
    5451089                                    );
    5461090
     1091
     1092
    5471093                                    $posts = get_posts($args);
    5481094
     1095
     1096
    5491097                                    if ($posts) {
    5501098
     1099
     1100
    5511101                                        foreach ($posts as $post) :
    5521102
     1103
     1104
    5531105                                            setup_postdata($post);
    5541106
     1107
     1108
    5551109                                            $selected = '';
    5561110
     1111
     1112
    5571113                                            //                    if (in_array($post->ID, $postids)) {
    5581114
     1115
     1116
    5591117                                            //                        $selected = "selected";
    5601118
     1119
     1120
    5611121                                            //                    }
    5621122
     1123
     1124
    5631125                                            $cd = get_post_meta($post->ID, 'condition_a1');
    5641126
     1127
     1128
    5651129//                                            echo '<pre>'.$post->ID.print_r($cd,true).'</pre>';
    5661130
     1131
     1132
    5671133                                            if (is_array($cd) && count($cd) > 0) {
    5681134
     1135
     1136
    5691137                                                // echo get_post_meta( $post->ID, 'condition_a1');
    5701138
     1139
     1140
    5711141                                                echo '<option value="' . $post->ID . '" ' . $selected . ' disabled >' . $post->post_title . '</option>';
    5721142
     1143
     1144
    5731145                                            } else {
    5741146
     1147
     1148
    5751149                                                //  echo get_post_meta( $post->ID, 'condition_a1');
    5761150
     1151
     1152
    5771153                                                echo '<option value="' . $post->ID . '" ' . $selected . ' >' . $post->post_title . '</option>';
    5781154
     1155
     1156
    5791157                                            }
    5801158
     1159
     1160
    5811161                                        endforeach;
    5821162
     1163
     1164
    5831165                                        wp_reset_postdata();
    5841166
     1167
     1168
    5851169                                    }
    5861170
    5871171
     1172
     1173
     1174
    5881175                                    ?>
    5891176
     1177
     1178
    5901179                                </select>
    5911180
     1181
     1182
    5921183                            </div>
    5931184
     1185
     1186
    5941187                        </div>
    5951188
     1189
     1190
    5961191                    </div>
    5971192
     1193
     1194
    5981195                    <div class="activation-container-box">
    5991196
     1197
     1198
    6001199                        <div class="activation-flex-box">
    6011200
     1201
     1202
    6021203                            <div class="master-template-option-container ">
    6031204
     1205
     1206
    6041207                                <div class="master-input-group">
    6051208
     1209
     1210
    6061211                                    <label class="attr-input-label"><?php esc_html_e('Conditions:', 'masterelements'); ?></label>
    6071212
     1213
     1214
    6081215                                    <div class="full-widthbox">
    6091216
     1217
     1218
    6101219                                        <div class="selection-box field-box margin-bottom20">
    6111220
     1221
     1222
    6121223                                            <select class="master-template-condition_a attr-form-control">
    6131224
     1225
     1226
    6141227                                                <?php if ($_GET['post_type'] == 'me_archive'): ?>
    6151228
     1229
     1230
    6161231                                                    <option value="archive"
     1232
    6171233                                                            class="disabled" <?php selected($condition_a, 'archive', true); ?>><?php esc_html_e('Archive ', 'masterelements'); ?></option>
    6181234
     1235
     1236
    6191237                                                <?php elseif ($_GET['post_type'] == 'me_maintenance' || $_GET['post_type'] == 'me_404'): ?>
    6201238
     1239
     1240
    6211241                                                    <option value="entire_site" <?php selected($condition_a, 'entire_site', true); ?>><?php esc_html_e('Entire Site', 'masterelements'); ?></option>
    6221242
     1243
     1244
    6231245                                                <?php elseif ($_GET['post_type'] == 'me_wooproduct'): ?>
    6241246
     1247
     1248
    6251249                                                    <option value=" "><?php esc_html_e('Choose Condition', 'masterelements'); ?></option>
    6261250
     1251
     1252
    6271253                                                    <option value="woo_single_product" <?php selected($condition_a, 'woo_single_product', true); ?>><?php esc_html_e('MW: Single Product Page', 'masterelements'); ?></option>
    6281254
     1255
     1256
    6291257                                                    <option value="woo_archive_product" <?php selected($condition_a, 'woo_archive_product', true); ?>><?php esc_html_e('MW: Archive Product Page', 'masterelements'); ?></option>
    6301258
     1259
     1260
    6311261                                                    <option value="woo_product_cart" <?php selected($condition_a, 'woo_product_cart', true); ?>><?php esc_html_e('MW: Cart Product Page', 'masterelements'); ?></option>
    6321262
     1263
     1264
    6331265                                                    <option value="woo_product_checkout" <?php selected($condition_a, 'woo_product_checkout', true); ?>><?php esc_html_e('MW: Product Checkout Page', 'masterelements'); ?></option>
    6341266
     1267
     1268
    6351269                                                    <option value="woo_my_account" <?php selected($condition_a, 'woo_my_account', true); ?>><?php esc_html_e('MW: My Account Page', 'masterelements'); ?></option>
    6361270
     1271
     1272
    6371273                                                    <option value="woo_thankyou_page" <?php selected($condition_a, 'woo_thankyou_page', true); ?>><?php esc_html_e('MW: Thankyou Page', 'masterelements'); ?></option>;
    6381274
     1275
     1276
    6391277                                                <?php else: ?>
    6401278
     1279
     1280
    6411281                                                    <option value="entire_site" <?php selected($condition_a, 'entire_site', true); ?>><?php esc_html_e('Entire Site', 'masterelements'); ?></option>
    6421282
     1283
     1284
    6431285                                                    <option value="singular" <?php selected($condition_a, 'singular', true); ?>><?php esc_html_e('Singular ', 'masterelements'); ?></option>
    6441286
     1287
     1288
    6451289                                                    <option value="archive" <?php selected($condition_a, 'archive', true); ?>><?php esc_html_e('Archive ', 'masterelements'); ?></option>
    6461290
     1291
     1292
    6471293                                                <?php endif; ?>
    6481294
     1295
     1296
    6491297                                            </select>
    6501298
     1299
     1300
    6511301                                            <input type="hidden" value="1" name="counterCondition"
     1302
    6521303                                                   id="counterCondition"
     1304
    6531305                                                   class="counterCondition">
    6541306
     1307
     1308
    6551309                                            <?php if ($_GET['post_type'] == 'me_archive'): ?>
    6561310
     1311
     1312
    6571313                                                <input type="hidden" value="archive" name="condition_a1"
     1314
    6581315                                                       id="condition_a1"
     1316
    6591317                                                       class="condition_a1">
    6601318
     1319
     1320
    6611321                                            <?php elseif ($_GET['post_type'] == 'me_wooproduct'): ?>
    6621322
     1323
     1324
    6631325                                                <input type="hidden" value="woo_single_product" name="condition_a1"
     1326
    6641327                                                       id="condition_a1"
     1328
    6651329                                                       class="condition_a1">
    6661330
     1331
     1332
    6671333                                                <input type="hidden" value="woo_archive_product" name="condition_a1"
     1334
    6681335                                                       id="condition_a1"
     1336
    6691337                                                       class="condition_a1">
    6701338
     1339
     1340
    6711341                                                <input type="hidden" value="woo_product_cart" name="condition_a1"
     1342
    6721343                                                       id="condition_a1"
     1344
    6731345                                                       class="condition_a1">
    6741346
     1347
     1348
    6751349                                                <input type="hidden" value="woo_product_checkout"
     1350
    6761351                                                       name="condition_a1"
     1352
    6771353                                                       id="condition_a1"
     1354
    6781355                                                       class="condition_a1">
    6791356
     1357
     1358
    6801359                                                <input type="hidden" value="woo_my_account" name="condition_a1"
     1360
    6811361                                                       id="condition_a1"
     1362
    6821363                                                       class="condition_a1">
    6831364
     1365
     1366
    6841367                                                <input type="hidden" value="woo_thankyou_page" name="condition_a1"
     1368
    6851369                                                       id="condition_a1"
     1370
    6861371                                                       class="condition_a1">
    6871372
     1373
     1374
    6881375                                            <?php else: ?>
     1376
    6891377                                                <input type="hidden" value="entire_site" name="condition_a1"
     1378
    6901379                                                       id="condition_a1"
     1380
    6911381                                                       class="condition_a1">
     1382
    6921383                                            <?php endif; ?>
    6931384
     1385
     1386
    6941387                                        </div>
    6951388
     1389
     1390
    6961391                                    </div>
    6971392
     1393
     1394
    6981395                                </div>
    6991396
    7001397
     1398
     1399
     1400
    7011401                                <?php
    7021402
     1403
     1404
    7031405                                $display = 'block';
    7041406
     1407
     1408
    7051409                                if ($condition_a != 'singular') {
    7061410
     1411
     1412
    7071413                                    $display = 'none';
    7081414
     1415
     1416
    7091417                                } ?>
    7101418
     1419
     1420
    7111421                                <div class="activation-flex-box">
    7121422
     1423
     1424
    7131425                                    <div class="master-input-group condition_singular"
     1426
    7141427                                         style="display: <?= $display; ?>">
    7151428
     1429
     1430
    7161431                                        <label class="attr-input-label"><?php echo __('Select Any:', 'masterelements'); ?></</label>
    7171432
     1433
     1434
    7181435                                        <select class="master-template-condition_singular attr-form-control">
    7191436
     1437
     1438
    7201439                                            <option value=""><?php echo __('Select Any', 'masterelements'); ?></
     1440
    7211441                                            </option>
    7221442
     1443
     1444
    7231445                                            <option value="all" <?php selected($condition_singular, 'all', true); ?>><?php esc_html_e('All Singulars', 'masterelements'); ?></option>
    7241446
     1447
     1448
    7251449                                            <option value="front_page" <?php selected($condition_singular, 'front_page', true); ?>><?php esc_html_e('Front Page', 'masterelements'); ?></option>
    7261450
     1451
     1452
    7271453                                            <option value="all_posts" <?php selected($condition_singular, 'all_posts', true); ?>><?php esc_html_e('All Posts', 'masterelements'); ?></option>
    7281454
     1455
     1456
    7291457                                            <option value="all_pages" <?php selected($condition_singular, 'all_pages', true); ?>><?php esc_html_e('All Pages', 'masterelements'); ?></option>
    7301458
     1459
     1460
    7311461                                            <option value="404page" <?php selected($condition_singular, '404page', true); ?>><?php esc_html_e('404 Page', 'masterelements'); ?></option>
    7321462
     1463
     1464
    7331465                                            <option value="selective" <?php selected($condition_singular, 'selective', true); ?>><?php esc_html_e('Selective Singular', 'masterelements'); ?></option>
    7341466
     1467
     1468
    7351469                                        </select>
    7361470
     1471
     1472
    7371473                                        <input type="hidden" name="condition_singular1" id="condition_singular1"
     1474
    7381475                                               class="condition_singular1">
    7391476
    7401477
     1478
     1479
     1480
    7411481                                    </div>
    7421482
     1483
     1484
    7431485                                    <br>
    7441486
     1487
     1488
    7451489                                    <?php
    7461490
     1491
     1492
    7471493                                    $display = 'block';
    7481494
     1495
     1496
    7491497                                    if ($condition_singular != 'selective') {
    7501498
     1499
     1500
    7511501                                        $display = 'none';
    7521502
     1503
     1504
    7531505                                    } ?>
    7541506
     1507
     1508
    7551509                                    <div class="master-template-condition_singular_id-container condition_singular_id"
     1510
    7561511                                         style="display: <?= $display; ?>">
    7571512
     1513
     1514
    7581515                                        <div class="master-input-group">
    7591516
     1517
     1518
    7601519                                            <label class="attr-input-label"><?php echo __('Select Any:', 'masterelements'); ?></</label>
    7611520
     1521
     1522
    7621523                                            <select style="width:150px;" multiple
     1524
    7631525                                                    class="master-template-modalinput-condition_singular_id select2">
    7641526
     1527
     1528
    7651529                                                <?php
    7661530
     1531
     1532
    7671533                                                $postids = array();
    7681534
     1535
     1536
    7691537                                                if (!empty($condition_singular_id)) {
    7701538
     1539
     1540
    7711541                                                    $postids = explode(',', $condition_singular_id);
    7721542
     1543
     1544
    7731545                                                }
    7741546
     1547
     1548
    7751549                                                $args = array(
    7761550
     1551
     1552
    7771553                                                    'public' => true,
    7781554
     1555
     1556
    7791557                                                );
    7801558
    7811559
     1560
     1561
     1562
    7821563                                                $output = 'names'; // 'names' or 'objects' (default: 'names')
    7831564
     1565
     1566
    7841567                                                $operator = 'and'; // 'and' or 'or' (default: 'and')
    7851568
    7861569
     1570
     1571
     1572
    7871573                                                $post_types = get_post_types($args, $output, $operator);
    7881574
    7891575
     1576
     1577
     1578
    7901579                                                if ($post_types) { // If there are any custom public post types.
    7911580
     1581
     1582
    7921583                                                    foreach ($post_types as $post_type) {
    7931584
     1585
     1586
    7941587                                                        $args = array(
    7951588
     1589
     1590
    7961591                                                            'numberposts' => -1,
    7971592
     1593
     1594
    7981595                                                            'post_type' => $post_type
    7991596
     1597
     1598
    8001599                                                        );
    8011600
     1601
     1602
    8021603                                                        $ecpt = array('metemplate', 'elementor_library', 'attachment');
    8031604
     1605
     1606
    8041607                                                        if (!in_array($post_type, $ecpt)) {
    8051608
     1609
     1610
    8061611                                                            $posts = get_posts($args);
    8071612
     1613
     1614
    8081615                                                            if ($posts) {
    8091616
     1617
     1618
    8101619                                                                foreach ($posts as $post) :
    8111620
     1621
     1622
    8121623                                                                    setup_postdata($post);
    8131624
     1625
     1626
    8141627                                                                    $selected = '';
    8151628
     1629
     1630
    8161631                                                                    if (in_array($post->ID, $postids)) {
    8171632
     1633
     1634
    8181635                                                                        $selected = "selected";
    8191636
     1637
     1638
    8201639                                                                    }
    8211640
     1641
     1642
    8221643                                                                    echo '<option value="' . $post->ID . '" ' . $selected . ' >' . $post->post_title . '</option>';
    8231644
     1645
     1646
    8241647                                                                endforeach;
    8251648
     1649
     1650
    8261651                                                                wp_reset_postdata();
    8271652
     1653
     1654
    8281655                                                            }
    8291656
     1657
     1658
    8301659                                                        }
    8311660
     1661
     1662
    8321663                                                    }
    8331664
     1665
     1666
    8341667                                                }
    8351668
    8361669
     1670
     1671
     1672
    8371673                                                ?>
    8381674
     1675
     1676
    8391677                                            </select>
    8401678
     1679
     1680
    8411681                                            <input type="hidden" name="condition_singular_id1[]"
     1682
    8421683                                                   id="condition_singular_id1" class="condition_singular_id1">
    8431684
    8441685
     1686
     1687
     1688
    8451689                                        </div>
    8461690
     1691
     1692
    8471693                                        <br/>
    8481694
     1695
     1696
    8491697                                    </div>
    8501698
     1699
     1700
    8511701                                    <br>
    8521702
     1703
     1704
    8531705                                </div>
    8541706
     1707
     1708
    8551709                            </div>
    8561710
     1711
     1712
    8571713                        </div>
    8581714
     1715
     1716
    8591717                    </div>
    8601718
     1719
     1720
    8611721                    <div id="newConditionTemplate">
    8621722
    8631723
     1724
     1725
     1726
    8641727                    </div>
    8651728
     1729
     1730
    8661731                </div>
    8671732
     1733
     1734
    8681735            </div>
    8691736
    8701737
     1738
     1739
     1740
    8711741            <button type="submit" class="option-btn"><?php echo __('Save Data', 'masterelements'); ?></button>
    8721742
     1743
     1744
    8731745            <?php if ($_GET['post_type'] != 'me_archive'): ?>
     1746
    8741747                <button type="button" id="addButton"
     1748
    8751749                        class="blue-btn"><?php echo __('Add more Condition', 'masterelements'); ?></button>
     1750
    8761751            <?php endif; ?>
    8771752
     1753
     1754
    8781755            <br>
    8791756
     1757
     1758
    8801759            <br>
    8811760
    8821761
     1762
     1763
     1764
    8831765        </form>
    8841766
     1767
     1768
    8851769        <div style="display: none" id="newRowDiv">
    8861770
     1771
     1772
    8871773            <div class="master-input-group">
    8881774
     1775
     1776
    8891777                <label class="attr-input-label"><?php esc_html_e('Conditions:', 'masterelements'); ?></label>
    8901778
     1779
     1780
    8911781                <select class="master-template-condition_a attr-form-control">
    8921782
     1783
     1784
    8931785                    <?php if ($_GET['post_type'] == 'me_archive'): ?>
    8941786
     1787
     1788
    8951789                        <option value="archive"
     1790
    8961791                                class="disabled" <?php selected($condition_a, 'archive', true); ?>><?php esc_html_e('Archive ', 'masterelements'); ?></option>
    8971792
     1793
     1794
    8981795                    <?php elseif ($_GET['post_type'] == 'me_wooproduct'): ?>
    8991796
     1797
     1798
    9001799                        <option value="woo_single_product"
     1800
    9011801                                class="disabled" <?php selected($condition_a, 'woo_single_product', true); ?>><?php esc_html_e('MW: Single Product Page', 'masterelements'); ?></option>
    9021802
     1803
     1804
    9031805                        <option value="woo_archive_product"
     1806
    9041807                                class="disabled" <?php selected($condition_a, 'woo_archive_product', true); ?>><?php esc_html_e('MW: Archive Product Page ', 'masterelements'); ?></option>
    9051808
     1809
     1810
    9061811                        <option value="woo_product_cart"
     1812
    9071813                                class="disabled" <?php selected($condition_a, 'woo_product_cart', true); ?>><?php esc_html_e('MW: Product Cart Page ', 'masterelements'); ?></option>
    9081814
     1815
     1816
    9091817                        <option value="woo_product_checkout"
     1818
    9101819                                class="disabled" <?php selected($condition_a, 'woo_product_checkout', true); ?>><?php esc_html_e('MW: Product Checkout Page ', 'masterelements'); ?></option>
    9111820
     1821
     1822
    9121823                        <option value="woo_my_account"
     1824
    9131825                                class="disabled" <?php selected($condition_a, 'woo_my_account', true); ?>><?php esc_html_e('MW: My Account Page ', 'masterelements'); ?></option>
    9141826
     1827
     1828
    9151829                        <option value="woo_thankyou_page"
     1830
    9161831                                class="disabled" <?php selected($condition_a, 'woo_thankyou_page', true); ?>><?php esc_html_e('MW: Thankyou Page ', 'masterelements'); ?></option>;
    9171832
     1833
     1834
    9181835                    <?php else: ?>
    9191836
     1837
     1838
    9201839                        <option value="entire_site" <?php selected($condition_a, 'entire_site', true); ?>><?php esc_html_e('Entire Site', 'masterelements'); ?></option>
    9211840
     1841
     1842
    9221843                        <option value="singular" <?php selected($condition_a, 'singular', true); ?>><?php esc_html_e('Singular ', 'masterelements'); ?></option>
    9231844
     1845
     1846
    9241847                        <option value="archive" <?php selected($condition_a, 'archive', true); ?>><?php esc_html_e('Archive ', 'masterelements'); ?></option>
    9251848
     1849
     1850
    9261851                    <?php endif; ?>
    9271852
     1853
     1854
    9281855                </select>
    9291856
     1857
     1858
    9301859                <!-- <button type="button" id="addButton" class="btn btn-primary">Add more Condition</button>
    9311860
     1861
     1862
    9321863                <button style="display: none" type="button" id="removeButton" class="btn btn-primary">Remove Condition</button> -->
    9331864
     1865
     1866
    9341867            </div>
    9351868
    9361869
     1870
     1871
     1872
    9371873            <?php
    9381874
     1875
     1876
    9391877            $display = 'block';
    9401878
     1879
     1880
    9411881            if ($condition_a != 'singular') {
    9421882
     1883
     1884
    9431885                $display = 'none';
    9441886
     1887
     1888
    9451889            } ?>
    9461890
     1891
     1892
    9471893            <div class="master-input-group condition_singular" style="display: <?= $display; ?>">
    9481894
     1895
     1896
    9491897                <label class="attr-input-label"><?php echo __('Select Any:', 'masterelements'); ?></label>
    9501898
     1899
     1900
    9511901                <select class="master-template-condition_singular attr-form-control">
    9521902
     1903
     1904
    9531905                    <option value=""><?php echo __('Select Any', 'masterelements'); ?></option>
    9541906
     1907
     1908
    9551909                    <option value="all" <?php selected($condition_singular, 'all', true); ?>><?php esc_html_e('All Singulars', 'masterelements'); ?></option>
    9561910
     1911
     1912
    9571913                    <option value="front_page" <?php selected($condition_singular, 'front_page', true); ?>><?php esc_html_e('Front Page', 'masterelements'); ?></option>
    9581914
     1915
     1916
    9591917                    <option value="all_posts" <?php selected($condition_singular, 'all_posts', true); ?>><?php esc_html_e('All Posts', 'masterelements'); ?></option>
    9601918
     1919
     1920
    9611921                    <option value="all_pages" <?php selected($condition_singular, 'all_pages', true); ?>><?php esc_html_e('All Pages', 'masterelements'); ?></option>
    9621922
     1923
     1924
    9631925                    <option value="404page" <?php selected($condition_singular, '404page', true); ?>><?php esc_html_e('404 Page', 'masterelements'); ?></option>
    9641926
     1927
     1928
    9651929                    <option value="selective" <?php selected($condition_singular, 'selective', true); ?>><?php esc_html_e('Selective Singular', 'masterelements'); ?></option>
    9661930
     1931
     1932
    9671933                </select>
    9681934
     1935
     1936
    9691937            </div>
    9701938
     1939
     1940
    9711941            <br>
    9721942
     1943
     1944
    9731945            <?php
    9741946
     1947
     1948
    9751949            $display = 'block';
    9761950
     1951
     1952
    9771953            if ($condition_singular != 'selective') {
    9781954
     1955
     1956
    9791957                $display = 'none';
    9801958
     1959
     1960
    9811961            } ?>
    9821962
     1963
     1964
    9831965            <div class="master-template-condition_singular_id-container condition_singular_id"
     1966
    9841967                 style="display: <?= $display; ?>">
    9851968
     1969
     1970
    9861971                <div class="master-input-group">
    9871972
     1973
     1974
    9881975                    <label class="attr-input-label"><?php echo __('Select Any:', 'masterelements'); ?></label>
    9891976
     1977
     1978
    9901979                    <select style="width:150px;" multiple
     1980
    9911981                            class="master-template-modalinput-condition_singular_id select2">
    9921982
     1983
     1984
    9931985                        <?php
    9941986
     1987
     1988
    9951989                        $postids = array();
    9961990
     1991
     1992
    9971993                        if (!empty($condition_singular_id)) {
    9981994
     1995
     1996
    9991997                            $postids = explode(',', $condition_singular_id);
    10001998
     1999
     2000
    10012001                        }
    10022002
     2003
     2004
    10032005                        $args = array(
    10042006
     2007
     2008
    10052009                            'public' => true,
    10062010
     2011
     2012
    10072013                        );
    10082014
    10092015
     2016
     2017
     2018
    10102019                        $output = 'names'; // 'names' or 'objects' (default: 'names')
    10112020
     2021
     2022
    10122023                        $operator = 'and'; // 'and' or 'or' (default: 'and')
    10132024
    10142025
     2026
     2027
     2028
    10152029                        $post_types = get_post_types($args, $output, $operator);
    10162030
    10172031
     2032
     2033
     2034
    10182035                        if ($post_types) { // If there are any custom public post types.
    10192036
     2037
     2038
    10202039                            foreach ($post_types as $post_type) {
    10212040
     2041
     2042
    10222043                                $args = array(
    10232044
     2045
     2046
    10242047                                    'numberposts' => -1,
    10252048
     2049
     2050
    10262051                                    'post_type' => $post_type
    10272052
     2053
     2054
    10282055                                );
    10292056
     2057
     2058
    10302059                                $ecpt = array('metemplate', 'elementor_library', 'attachment');
    10312060
     2061
     2062
    10322063                                if (!in_array($post_type, $ecpt)) {
    10332064
     2065
     2066
    10342067                                    $posts = get_posts($args);
    10352068
     2069
     2070
    10362071                                    if ($posts) {
    10372072
     2073
     2074
    10382075                                        foreach ($posts as $post) :
    10392076
     2077
     2078
    10402079                                            setup_postdata($post);
    10412080
     2081
     2082
    10422083                                            $selected = '';
    10432084
     2085
     2086
    10442087                                            if (in_array($post->ID, $postids)) {
    10452088
     2089
     2090
    10462091                                                $selected = "selected";
    10472092
     2093
     2094
    10482095                                            }
    10492096
     2097
     2098
    10502099                                            echo '<option value="' . $post->ID . '" ' . $selected . ' >' . $post->post_title . '</option>';
    10512100
     2101
     2102
    10522103                                        endforeach;
    10532104
     2105
     2106
    10542107                                        wp_reset_postdata();
    10552108
     2109
     2110
    10562111                                    }
    10572112
     2113
     2114
    10582115                                }
    10592116
     2117
     2118
    10602119                            }
    10612120
     2121
     2122
    10622123                        }
    10632124
    10642125
     2126
     2127
     2128
    10652129                        ?>
    10662130
     2131
     2132
    10672133                    </select>
    10682134
    10692135
     2136
     2137
     2138
    10702139                </div>
    10712140
    10722141
     2142
     2143
     2144
    10732145                <br/>
    10742146
     2147
     2148
    10752149            </div>
    10762150
    10772151
     2152
     2153
     2154
    10782155            <br>
    10792156
    10802157
     2158
     2159
     2160
    10812161        </div>
    10822162
    10832163
     2164
     2165
     2166
    10842167        <?php
    10852168
     2169
     2170
    10862171        if (isset($_POST) && !empty($_POST) && !empty($_POST['type'] && isset($_POST['counterCondition']))) {
    10872172
     2173
     2174
    10882175            for ($index = 1; $index <= $_POST['counterCondition']; $index++) {
    10892176
     2177
     2178
    10902179                if (isset($_POST['condition_a' . $index])) {
    10912180
     2181
     2182
    10922183                    if (metadata_exists('post', $_POST['type'], $_POST['condition_a' . $index])) {
     2184
    10932185                        update_post_meta($_POST['type'], 'condition_a' . $index, $_POST['condition_a' . $index]);
    10942186
     2187
     2188
    10952189                    } else {
     2190
    10962191                        add_post_meta($_POST['type'], 'condition_a' . $index, $_POST['condition_a' . $index]);
    10972192
     2193
     2194
    10982195                    }
    10992196
    11002197
     2198
     2199
     2200
    11012201                }
    11022202
     2203
     2204
    11032205                if ($_POST['condition_a' . $index] == 'singular') {
    11042206
     2207
     2208
    11052209                    if (isset($_POST['condition_singular' . $index])) {
    11062210
     2211
     2212
    11072213                        if (metadata_exists('post', $_POST['type'], $_POST['condition_singular' . $index])) {
    11082214
     2215
     2216
    11092217                            update_post_meta($_POST['type'], 'condition_singular' . $index, $_POST['condition_singular' . $index]);
    11102218
     2219
     2220
    11112221                        } else {
    11122222
     2223
     2224
    11132225                            add_post_meta($_POST['type'], 'condition_singular' . $index, $_POST['condition_singular' . $index]);
    11142226
     2227
     2228
    11152229                        }
    11162230
    11172231
     2232
     2233
     2234
    11182235                    }
    11192236
     2237
     2238
    11202239                    if (isset($_POST['condition_singular_id' . $index])) {
    11212240
     2241
     2242
    11222243                        if (metadata_exists('post', $_POST['type'], $_POST['condition_singular_id' . $index])) {
    11232244
     2245
     2246
    11242247                            update_post_meta($_POST['type'], 'condition_singular_id', $index, $_POST['condition_singular_id' . $index]);
    11252248
     2249
     2250
    11262251                        } else {
    11272252
     2253
     2254
    11282255                            add_post_meta($_POST['type'], 'condition_singular_id' . $index, $_POST['condition_singular_id' . $index]);
    11292256
     2257
     2258
    11302259                        }
    11312260
    11322261
     2262
     2263
     2264
    11332265                    }
    11342266
     2267
     2268
    11352269                } else {
    11362270
     2271
     2272
    11372273                    update_post_meta($_POST['type'], 'condition_singular' . $index, '');
    11382274
     2275
     2276
    11392277                    update_post_meta($_POST['type'], 'condition_singular_id' . $index, '');
    11402278
     2279
     2280
    11412281                }
    11422282
    11432283
     2284
     2285
     2286
    11442287            }
    11452288
     2289
     2290
    11462291            if (metadata_exists('activation', $_POST['type'], $_POST['activation'])) {
    11472292
     2293
     2294
    11482295                update_post_meta($_POST['type'], 'activation', $_POST['activation']);
    11492296
     2297
     2298
    11502299            } else {
    11512300
     2301
     2302
    11522303                add_post_meta($_POST['type'], 'activation', $_POST['activation']);
    11532304
    11542305
     2306
     2307
     2308
    11552309            }
    11562310
     2311
     2312
    11572313            if (metadata_exists('counterCondition', $_POST['type'], $_POST['counterCondition'])) {
    11582314
     2315
     2316
    11592317                update_post_meta($_POST['type'], 'counterCondition', $_POST['counterCondition']);
    11602318
     2319
     2320
    11612321            } else {
    11622322
     2323
     2324
    11632325                add_post_meta($_POST['type'], 'counterCondition', $_POST['counterCondition']);
    11642326
    11652327
     2328
     2329
     2330
    11662331            }
    11672332
     2333
     2334
    11682335            //  print_r(get_post_meta($_POST['type']));
    11692336
     2337
     2338
    11702339        }
    11712340
     2341
     2342
    11722343// } else {
    11732344
     2345
     2346
    11742347//     echo "Please Select Template";
    11752348
     2349
     2350
    11762351// }
    11772352
     2353
     2354
    11782355        if (isset($_POST) && isset($_POST['update']) && !empty($_POST['postmetaids']) && !empty($_POST['postmetatypes'])) {
    11792356
     2357
     2358
    11802359            echo $_POST;
    11812360
     2361
     2362
    11822363            exit();
    11832364
     2365
     2366
    11842367        }
    11852368
     2369
     2370
    11862371        ?>
    11872372
    11882373
     2374
     2375
     2376
    11892377        <br>
    11902378
     2379
     2380
    11912381        <div class="meta-template-option-listing">
    11922382
     2383
     2384
    11932385            <table class="table">
    11942386
     2387
     2388
    11952389                <?php
     2390
    11962391                $args = array(
     2392
    11972393                    'post_type' => $_GET['post_type'],
     2394
    11982395                    'post_status' => array('publish'),
     2396
    11992397                    'order' => 'ASC'
     2398
    12002399                );
    12012400
     2401
     2402
    12022403                $posts = query_posts($args);
     2404
    12032405                ?>
    12042406
     2407
     2408
    12052409                <tr>
    12062410
     2411
     2412
    12072413                    <th><?php echo __('Template', 'masterelements'); ?></th>
    12082414
     2415
     2416
    12092417                    <th><?php echo __('Conditions', 'masterelements'); ?></th>
    12102418
     2419
     2420
    12112421                    <th><?php echo __('Activation', 'masterelements'); ?></th>
    12122422
     2423
     2424
    12132425                </tr>
    12142426
     2427
     2428
    12152429                <?php
    12162430
     2431
     2432
    12172433                if ($posts) {
    12182434
     2435
     2436
    12192437                    foreach ($posts as $post) :
    12202438
     2439
     2440
    12212441                        setup_postdata($post);
     2442
    12222443                        ?>
    12232444
    12242445
     2446
     2447
     2448
    12252449                        <tr>
     2450
    12262451                            <td> <?= $post->post_title ?></td>
     2452
    12272453                            <td>
    12282454
     2455
     2456
    12292457                                <?php $conditionCounter = get_post_meta($post->ID, 'counterCondition', true);
    12302458
     2459
     2460
    12312461                                for ($index = 1; $index <= $conditionCounter; $index++) {
    12322462
     2463
     2464
    12332465                                    $ca = 'condition_a' . $index;
    12342466
     2467
     2468
    12352469                                    $cs = 'condition_singular' . $index;
    12362470
     2471
     2472
    12372473                                    $csid = 'condition_singular_id' . $index;
    12382474
     2475
     2476
    12392477                                    echo $cad = get_post_meta($post->ID, $ca, true);
    12402478
     2479
     2480
    12412481                                    $cr = get_post_meta($post->ID, $cs, true);
    12422482
     2483
     2484
    12432485                                    // echo '<pre>'.print_r($cr,true).'</pre>';
    12442486
     2487
     2488
    12452489                                    if ($cad === 'singular' && !empty($cr)) {
    12462490
     2491
     2492
    12472493                                        echo ' > ' . $cr;
    12482494
     2495
     2496
    12492497                                    }
    12502498
     2499
     2500
    12512501                                    if ($cr == 'selective') {
    12522502
     2503
     2504
    12532505                                        print_r(' > ' . implode(',', get_post_meta($post->ID, $csid, true)));
    12542506
     2507
     2508
    12552509                                    }
    12562510
     2511
     2512
    12572513                                    if (!empty($cad) || !empty($cr) || !empty(get_post_meta($post->ID, $csid, true))) {
    12582514
     2515
     2516
    12592517                                        echo '<div class="mastter-post-metaids">
    12602518
     2519
     2520
    12612521                     <input type="hidden" class="templatePostMetaIds" value="' . self::get_mid_by_key($post->ID, 'condition_a' . $index) . ',' . self::get_mid_by_key($post->ID, 'condition_singular' . $index) . ',' . self::get_mid_by_key($post->ID, 'condition_singular_id' . $index) . '">
    12622522
     2523
     2524
    12632525       
    12642526
     2527
     2528
    12652529                    <input type="hidden" class="templatePostMetatypes" value="condition_a' . $index . ',condition_singular' . $index . ',condition_singular_id' . $index . '">
    12662530
     2531
     2532
    12672533                    <button class="editPostcondition btn btn-primary btn xs" id="editPostcondition" type="button">Edit</button>
    12682534
     2535
     2536
    12692537                    <button id="removePostcondition" class="removePostcondition btn btn-danger btn-xs" type="button">Remove</button></div>';
    12702538
    12712539
     2540
     2541
     2542
    12722543                                        //$var =  self::get_complete_meta(152);
    12732544
     2545
     2546
    12742547                                        // echo $var[0]->meta_value;
    12752548
     2549
     2550
    12762551                                    }
    12772552
     2553
     2554
    12782555                                    echo '<br>';
    12792556
     2557
     2558
    12802559                                }
    12812560
     2561
     2562
    12822563                                //$activation = (isset($settings[$type['id']]['name']) &&$settings[$type['id']]['name'] = $type['id'])?$settings[$type['id']]['value']:'no';
    12832564
     2565
     2566
    12842567                                // echo '<pre>'. $activation.'<pre>';
    12852568
     2569
     2570
    12862571                                $activation = get_post_meta($post->ID, 'activation', true);
    12872572
    12882573
     2574
     2575
     2576
    12892577                                ?>
    12902578
     2579
     2580
    12912581                            </td>
     2582
    12922583                            <td>
    12932584
     2585
     2586
    12942587                                <div class="master-switch-group">
    12952588
     2589
     2590
    12962591                                    <label class="attr-input-label"><?php esc_html_e('Activation:', 'masterelements'); ?></label>
    12972592
     2593
     2594
    12982595                                    <div class="master-admin-input-switch2">
    12992596
     2597
     2598
    13002599                                        <input type="checkbox" value="<?= $activation; ?>"
     2600
    13012601                                               data-id="<?= $post->ID; ?>"
     2602
    13022603                                               class="master-admin-control-input  master-filed-activation master-template-activition master-active-<?= $activation; ?>"
     2604
    13032605                                               name="activation_val">
    13042606
     2607
     2608
    13052609                                        <label class="master-admin-control-label"
     2610
    13062611                                               for="master_activation_modal_input">
    13072612
     2613
     2614
    13082615                                    <span class="master-admin-control-label-switch" data-active="ON"
    13092616
     2617
     2618
    13102619                                          data-inactive="OFF"></span>
    13112620
     2621
     2622
    13122623                                        </label>
    13132624
     2625
     2626
    13142627                                        <input type="hidden" name="type" class="post_id_<?= $post->ID; ?>"
     2628
    13152629                                               value="<?= $post->ID; ?>">
    13162630
     2631
     2632
    13172633                                        <input type="hidden" class="activation_filed_<?= $post->ID; ?>"
     2634
    13182635                                               name="activation"
    13192636
     2637
     2638
    13202639                                               value="<?= (!empty($activation) ? $activation : 'yes?no'); ?>">
    13212640
     2641
     2642
    13222643                                    </div>
     2644
    13232645                                </div>
     2646
    13242647                            </td>
     2648
    13252649                        </tr>
    13262650
     2651
     2652
    13272653                    <?php endforeach;
    13282654
     2655
     2656
    13292657                    wp_reset_postdata();
    13302658
    13312659
     2660
     2661
     2662
    13322663                }
    13332664
     2665
     2666
    13342667                ?>
    13352668
     2669
     2670
    13362671            </table>
    13372672
    13382673
     2674
     2675
     2676
    13392677            <!-- Link to open the modal -->
    13402678
     2679
     2680
    13412681            <div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
    13422682
     2683
     2684
    13432685                <div class="modal-dialog" role="document">
    13442686
     2687
     2688
    13452689                    <div class="modal-content">
    13462690
     2691
     2692
    13472693                        <div class="modal-header">
    13482694
     2695
     2696
    13492697                            <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span
     2698
    13502699                                        aria-hidden="true">&times;</span></button>
    13512700
     2701
     2702
    13522703                            <h4 class="modal-title"
     2704
    13532705                                id="myModalLabel"><?php echo __('Update Condition', 'masterelements'); ?></h4>
    13542706
     2707
     2708
    13552709                        </div>
    13562710
     2711
     2712
    13572713                        <div class="modal-body">
    13582714
    13592715
     2716
     2717
     2718
    13602719                            <?php
    13612720
     2721
     2722
    13622723                            ?>
    13632724
     2725
     2726
    13642727                            <div class="master-template-option-container modal-parent-container">
    13652728
     2729
     2730
    13662731                                <input type="hidden" class="postmetaidsvalues" id="postmetaids" name="postmetaids"
     2732
    13672733                                       value="">
    13682734
     2735
     2736
    13692737                                <input type="hidden" class="postmetaidsvalues" id="postmetatypes"
     2738
    13702739                                       name="postmetatypes"
     2740
    13712741                                       value="">
    13722742
     2743
     2744
    13732745                                <div class="master-input-group">
    13742746
     2747
     2748
    13752749                                    <label class="attr-input-label"><?php esc_html_e('Conditions:', 'masterelements'); ?></label>
    13762750
     2751
     2752
    13772753                                    <select name="condition_a" id="master-template-condition_a_popup"
     2754
    13782755                                            class="master-template-condition_a attr-form-control">
    13792756
     2757
     2758
    13802759                                    </select>
    13812760
     2761
     2762
    13822763                                </div>
    13832764
    13842765
     2766
     2767
     2768
    13852769                                <?php
    13862770
     2771
     2772
    13872773                                // $display = 'block';
    13882774
     2775
     2776
    13892777                                // if($condition_a!='singular'){
    13902778
     2779
     2780
    13912781                                //     $display = 'none';
    13922782
     2783
     2784
    13932785                                // }
     2786
    13942787                                ?>
    13952788
     2789
     2790
    13962791                                <div class="master-input-group condition_singular"
     2792
    13972793                                     id="master-template-condition_singular-container">
    13982794
     2795
     2796
    13992797                                    <label class="attr-input-label"><?php echo __('Select Any', 'masterelements'); ?></</label>
    14002798
     2799
     2800
    14012801                                    <select name="condition_singular"
     2802
    14022803                                            class="master-template-condition_singular attr-form-control"
     2804
    14032805                                            id="master-template-condition_singular_popup">
    14042806
     2807
     2808
    14052809                                    </select>
    14062810
     2811
     2812
    14072813                                </div>
    14082814
     2815
     2816
    14092817                                <br>
    14102818
     2819
     2820
    14112821                                <?php
    14122822
     2823
     2824
    14132825                                // $display = 'block';
    14142826
     2827
     2828
    14152829                                // if($condition_singular!='selective'){
    14162830
     2831
     2832
    14172833                                //     $display = 'none';
    14182834
     2835
     2836
    14192837                                // }
     2838
    14202839                                ?>
    14212840
     2841
     2842
    14222843                                <div class="master-template-condition_singular_id-container condition_singular_id"
     2844
    14232845                                     id="master-template-condition_singular_id-container">
    14242846
     2847
     2848
    14252849                                    <div class="master-input-group">
    14262850
     2851
     2852
    14272853                                        <label class="attr-input-label"><?php echo __('Select Any', 'masterelements'); ?></</label>
    14282854
     2855
     2856
    14292857                                        <select name="condition_singular_id" style="width:150px;" multiple
     2858
    14302859                                                class="master-template-modalinput-condition_singular_id select2"
     2860
    14312861                                                id="master-template-condition_singular_id_popup">
    14322862
    14332863
     2864
     2865
     2866
    14342867                                        </select>
    14352868
     2869
     2870
    14362871                                    </div>
    14372872
     2873
     2874
    14382875                                    <br/>
    14392876
     2877
     2878
    14402879                                </div>
    14412880
     2881
     2882
    14422883                                <br>
    14432884
     2885
     2886
    14442887                                <button type="button" class="btn btn-primary update_post_condition_modal"
     2888
    14452889                                        name="update"
     2890
    14462891                                        value="Update">Update
     2892
    14472893                                </button>
    14482894
    14492895
     2896
     2897
     2898
    14502899                            </div>
     2900
    14512901                        </div>
    14522902
     2903
     2904
    14532905                        <div class="modal-footer">
    14542906
     2907
     2908
    14552909                            <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
    14562910
    14572911
     2912
     2913
     2914
    14582915                        </div>
    14592916
     2917
     2918
    14602919                    </div>
    14612920
     2921
     2922
    14622923                </div>
    14632924
     2925
     2926
    14642927            </div>
    14652928
     2929
     2930
    14662931        </div>
    14672932
     2933
     2934
    14682935        <?php
     2936
    14692937    }
    14702938
    14712939
     2940
     2941
     2942
    14722943    function get_mid_by_key($post_id, $meta_key)
     2944
    14732945    {
    14742946
     2947
     2948
    14752949        global $wpdb;
    14762950
     2951
     2952
    14772953        $mid = $wpdb->get_var($wpdb->prepare("SELECT meta_id FROM $wpdb->postmeta WHERE post_id = %d AND meta_key = %s", $post_id, $meta_key));
    14782954
     2955
     2956
    14792957        if ($mid != '')
    14802958
     2959
     2960
    14812961            return (int)$mid;
    14822962
    14832963
     2964
     2965
     2966
    14842967        return 0;
    14852968
     2969
     2970
    14862971    }
    14872972
     2973
     2974
    14882975    function get_complete_meta($meta_id)
     2976
    14892977    {
    14902978
     2979
     2980
    14912981        global $wpdb;
    14922982
     2983
     2984
    14932985        $data = $wpdb->get_results($wpdb->prepare("SELECT * FROM $wpdb->postmeta WHERE meta_id = $meta_id"));
    14942986
     2987
     2988
    14952989// echo "<pre>".print_r($data[0],true)."</pre>";
    14962990
    14972991
     2992
     2993
     2994
    14982995        if ($data != '') {
    14992996
     2997
     2998
    15002999            return $data;
    15013000
     3001
     3002
    15023003        } else {
    15033004
     3005
     3006
    15043007            return false;
    15053008
     3009
     3010
    15063011        }
    15073012
    15083013
     3014
     3015
     3016
    15093017    }
    15103018
    15113019
     3020
     3021
     3022
    15123023    function load_canvas_template($single_template)
     3024
    15133025    {
    15143026
    15153027
     3028
     3029
     3030
    15163031        global $post;
    15173032
     3033
     3034
    15183035        $posttypes = $template_types = $this->register_sections();
    15193036
     3037
     3038
    15203039        foreach ($posttypes as $posttype)
    15213040
     3041
     3042
    15223043            if ($posttype['id'] == $post->post_type) {
    15233044
    15243045
     3046
     3047
     3048
    15253049                $elementor_2_0_canvas = ELEMENTOR_PATH . '/modules/page-templates/templates/canvas.php';
    15263050
    15273051
     3052
     3053
     3054
    15283055                if (file_exists($elementor_2_0_canvas)) {
    15293056
     3057
     3058
    15303059                    return $elementor_2_0_canvas;
    15313060
     3061
     3062
    15323063                } else {
    15333064
     3065
     3066
    15343067                    return ELEMENTOR_PATH . '/includes/page-templates/canvas.php';
    15353068
     3069
     3070
    15363071                }
    15373072
     3073
     3074
    15383075            }
    15393076
    15403077
     3078
     3079
     3080
    15413081        return $single_template;
    15423082
     3083
     3084
    15433085    }
    15443086
     3087
     3088
    15453089    function register_sections()
     3090
    15463091    {
    15473092
     3093
     3094
    15483095        return $posttypes = [
    15493096
     3097
     3098
    15503099            'header' => [
    15513100
     3101
     3102
    15523103                'name' => 'Header',
    15533104
     3105
     3106
    15543107                'id' => 'me_header',
    15553108
     3109
     3110
    15563111                'd_addons' => array('site_navigation'),
    15573112
     3113
     3114
    15583115                'single' => 'Header Template',
    15593116
     3117
     3118
    15603119                'icon' => \MasterElements::assets_url() . 'images/icons/header.png',
    15613120
     3121
     3122
    15623123                'item' => 'Header',
    15633124
     3125
     3126
    15643127            ],
    15653128
     3129
     3130
    15663131            'footer' => [
    15673132
     3133
     3134
    15683135                'name' => 'Footer',
    15693136
     3137
     3138
    15703139                'id' => 'me_footer',
    15713140
     3141
     3142
    15723143                'd_addons' => array(''),
    15733144
     3145
     3146
    15743147                'single' => 'Footer Template',
    15753148
     3149
     3150
    15763151                'icon' => \MasterElements::assets_url() . 'images/icons/footer.png',
    15773152
     3153
     3154
    15783155                'item' => 'Footer',
    15793156
     3157
     3158
    15803159            ],
    15813160
     3161
     3162
    15823163            'archive' => [
    15833164
     3165
     3166
    15843167                'name' => 'Archive',
    15853168
     3169
     3170
    15863171                'id' => 'me_archive',
    15873172
     3173
     3174
    15883175                'd_addons' => array(''),
    15893176
     3177
     3178
    15903179                'single' => 'Archive Template',
    15913180
     3181
     3182
    15923183                'icon' => \MasterElements::assets_url() . 'images/icons/archive.png',
    15933184
     3185
     3186
    15943187                'item' => 'Archive',
    15953188
     3189
     3190
    15963191            ],
    15973192
     3193
     3194
    15983195            'single' => [
    15993196
     3197
     3198
    16003199                'name' => 'Single',
    16013200
     3201
     3202
    16023203                'id' => 'me_single',
    16033204
     3205
     3206
    16043207                'd_addons' => array(''),
    16053208
     3209
     3210
    16063211                'single' => 'Single Template',
    16073212
     3213
     3214
    16083215                'icon' => \MasterElements::assets_url() . 'images/icons/single.png',
    16093216
     3217
     3218
    16103219                'item' => 'Single',
    16113220
     3221
     3222
    16123223            ],
    16133224
     3225
     3226
    16143227            '404' => [
    16153228
     3229
     3230
    16163231                'name' => '404',
    16173232
     3233
     3234
    16183235                'id' => 'me_404',
    16193236
     3237
     3238
    16203239                'd_addons' => array(''),
    16213240
     3241
     3242
    16223243                'single' => '404 Template',
    16233244
     3245
     3246
    16243247                'icon' => \MasterElements::assets_url() . 'images/icons/404.png',
    16253248
     3249
     3250
    16263251                'item' => '404',
    16273252
     3253
     3254
    16283255            ],
    16293256
     3257
     3258
    16303259            'blog' => [
    16313260
     3261
     3262
    16323263                'name' => 'Blog Page',
    16333264
     3265
     3266
    16343267                'id' => 'me_blog',
    16353268
     3269
     3270
    16363271                'd_addons' => array(''),
    16373272
     3273
     3274
    16383275                'single' => 'Blog Template',
    16393276
     3277
     3278
    16403279                'icon' => \MasterElements::assets_url() . 'images/icons/blog.png',
    16413280
     3281
     3282
    16423283                'item' => 'Blog',
    16433284
     3285
     3286
    16443287            ],
    16453288
     3289
     3290
    16463291            'Maintenance' => [
    16473292
     3293
     3294
    16483295                'name' => 'Under Maintenance',
    16493296
     3297
     3298
    16503299                'id' => 'me_maintenance',
    16513300
     3301
     3302
    16523303                'd_addons' => array(''),
    16533304
     3305
     3306
    16543307                'single' => 'Maintenance Template',
    16553308
     3309
     3310
    16563311                'icon' => \MasterElements::assets_url() . 'images/icons/maintenance.png',
    16573312
     3313
     3314
    16583315                'item' => 'Maintenance',
    16593316
     3317
     3318
    16603319            ],
    16613320
     3321
     3322
    16623323            'Section' => [
    16633324
     3325
     3326
    16643327                'name' => 'Section',
    16653328
     3329
     3330
    16663331                'id' => 'me_section',
    16673332
     3333
     3334
    16683335                'd_addons' => array(''),
    16693336
     3337
     3338
    16703339                'single' => 'Section Template',
    16713340
     3341
     3342
    16723343                'icon' => \MasterElements::assets_url() . 'images/icons/section.png',
    16733344
     3345
     3346
    16743347                'item' => 'Section',
    16753348
     3349
     3350
    16763351            ],
    16773352
     3353
     3354
    16783355            'Search' => [
    16793356
     3357
     3358
    16803359                'name' => 'Search',
    16813360
     3361
     3362
    16823363                'id' => 'me_search',
    16833364
     3365
     3366
    16843367                'd_addons' => array(''),
    16853368
     3369
     3370
    16863371                'single' => 'Search Template',
    16873372
     3373
     3374
    16883375                'icon' => \MasterElements::assets_url() . 'images/icons/search.png',
    16893376
     3377
     3378
    16903379                'item' => 'Search',
    16913380
     3381
     3382
    16923383            ],
    16933384
     3385
     3386
    16943387            'Coming Soon' => [
    16953388
     3389
     3390
    16963391                'name' => 'Coming Soon',
    16973392
     3393
     3394
    16983395                'id' => 'me_comingsoon',
    16993396
     3397
     3398
    17003399                'd_addons' => array(''),
    17013400
     3401
     3402
    17023403                'single' => 'Coming Soon Template',
    17033404
     3405
     3406
    17043407                'icon' => \MasterElements::assets_url() . 'images/icons/coming_soon.png',
    17053408
     3409
     3410
    17063411                'item' => 'Coming Soon',
    17073412
     3413
     3414
    17083415            ],
    17093416
     3417
     3418
    17103419            'Mega Menu' => [
    17113420
     3421
     3422
    17123423                'name' => 'Mega Menu',
    17133424
     3425
     3426
    17143427                'id' => 'me_megamenu',
    17153428
     3429
     3430
    17163431                'd_addons' => array(''),
    17173432
     3433
     3434
    17183435                'single' => 'Mega Menu Template',
    17193436
     3437
     3438
    17203439                'icon' => \MasterElements::assets_url() . 'images/icons/coming_soon.png',
    17213440
     3441
     3442
    17223443                'item' => 'Mega Menu',
    17233444
     3445
     3446
    17243447            ],
    17253448
     3449
     3450
    17263451            'Nested Sections' => [
    17273452
     3453
     3454
    17283455                'name' => 'Nested Sections',
    17293456
     3457
     3458
    17303459                'id' => 'me_nested_sections',
    17313460
     3461
     3462
    17323463                'd_addons' => array(''),
    17333464
     3465
     3466
    17343467                'single' => 'Nested Sections',
    17353468
     3469
     3470
    17363471                //'icon' => \MasterElements::assets_url() . 'images/icons/woo.png',
    17373472
     3473
     3474
    17383475                'item' => 'Nested Sections',
     3476
    17393477            ],
    17403478
     3479
     3480
    17413481            'Woocommerce Page' => [
    17423482
     3483
     3484
    17433485                'name' => 'WooCommerce Page',
    17443486
     3487
     3488
    17453489                'id' => 'me_wooproduct',
    17463490
     3491
     3492
    17473493                'd_addons' => array('me_woo_products'),
    17483494
     3495
     3496
    17493497                'single' => 'Wooproduct Template',
    17503498
     3499
     3500
    17513501                //'icon' => \MasterElements::assets_url() . 'images/icons/woo.png',
    17523502
     3503
     3504
    17533505                'item' => 'WooCommerce Page',
     3506
    17543507            ],
    17553508
    17563509
     3510
     3511
     3512
    17573513        ];
    17583514
     3515
     3516
    17593517    }
    17603518
     3519
     3520
    17613521    // Create table For Theme Builder Settings
    17623522
     3523
     3524
    17633525    function create_table()
     3526
    17643527    {
    17653528
     3529
     3530
    17663531        global $wpdb;
    17673532
     3533
     3534
    17683535        require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
    17693536
    17703537
     3538
     3539
     3540
    17713541        /************* Creating Fileds table ************/
    17723542
     3543
     3544
    17733545        $table_name1 = $wpdb->prefix . "me_settings";
    17743546
     3547
     3548
    17753549        if ($wpdb->get_var("show tables like '" . $table_name1 . "'") != $table_name1) {
    17763550
     3551
     3552
    17773553            $sql = "CREATE TABLE " . $table_name1 . "(
    17783554
     3555
     3556
    17793557                     id int(11) NOT NULL AUTO_INCREMENT,
    17803558
     3559
     3560
    17813561                     name VARCHAR(255) NOT NULL,
    17823562
     3563
     3564
    17833565                     value VARCHAR(20) NOT NULL,
    17843566
     3567
     3568
    17853569                     PRIMARY KEY (id)
    17863570
     3571
     3572
    17873573                  ) ENGINE=InnoDB  DEFAULT CHARSET=utf8 AUTO_INCREMENT=0; ";
    17883574
    17893575
     3576
     3577
     3578
    17903579            dbDelta($sql);
    17913580
     3581
     3582
    17923583        }
    17933584
     3585
     3586
    17943587    }
    17953588
     3589
     3590
    17963591    // Retrieve data Theme Builder Settings table
    17973592
     3593
     3594
    17983595    function get_main_settings_data()
    17993596
     3597
     3598
    18003599    {
     3600
    18013601        global $wpdb;
    18023602
     3603
     3604
    18033605        $fields_table_name = $wpdb->prefix . "me_settings";
    18043606
     3607
     3608
    18053609        $query = "SELECT * FROM " . $fields_table_name;
    18063610
     3611
     3612
    18073613        $ds = $wpdb->get_results($query, ARRAY_A);
     3614
    18083615        $data = [];
    18093616
     3617
     3618
    18103619        foreach ($ds as $d) {
    18113620
     3621
     3622
    18123623            $data[$d['name']] = $d;
    18133624
     3625
     3626
    18143627        }
    18153628
     3629
     3630
    18163631        return $data;
     3632
    18173633    }
    18183634
     3635
     3636
    18193637    // Save data for Theme Builder Settings table
    18203638
     3639
     3640
    18213641    function save_me_settings()
     3642
    18223643    {
     3644
    18233645        global $wpdb;
     3646
    18243647        $table_name = $wpdb->prefix . "me_settings";
    18253648
     3649
     3650
    18263651        if ($_GET['addon'] != '') {
     3652
    18273653            $status_arr = explode(',', $_GET['addon']);
     3654
    18283655            $status_arr[count($status_arr)] = $_GET['type'];
     3656
    18293657        } else {
     3658
    18303659            $status_arr[0] = $_GET['type'];
     3660
    18313661        }
    18323662
     3663
     3664
    18333665        for ($i = 0; $i < count($status_arr); $i++) {
     3666
    18343667            $total = $wpdb->get_var("SELECT count(*) FROM " . $table_name . " where name='" . $status_arr[$i] . "'");
    18353668
     3669
     3670
    18363671            if ($total < 1) {
    18373672
     3673
     3674
    18383675                $wpdb->query($wpdb->prepare("INSERT INTO " . $table_name . " (name,value) VALUES (%s,%s)", $status_arr[$i], $_GET['status']));
    18393676
     3677
     3678
    18403679            } else {
    18413680
     3681
     3682
    18423683                $wpdb->update(
    18433684
     3685
     3686
    18443687                    $table_name,
    18453688
     3689
     3690
    18463691                    array(
    18473692
     3693
     3694
    18483695                        'value' => stripslashes($_GET['status']),
    18493696
     3697
     3698
    18503699                    ),
    18513700
     3701
     3702
    18523703                    array('name' => $status_arr[$i]),
    18533704
     3705
     3706
    18543707                    array(
    18553708
     3709
     3710
    18563711                        '%s',
    18573712
     3713
     3714
    18583715                    )
    18593716
     3717
     3718
    18603719                );
    18613720
     3721
     3722
    18623723            }
     3724
    18633725        }
    18643726
     3727
     3728
    18653729        echo json_encode(array('status' => 'success', 'msg' => 'Settings Updated'));
    18663730
     3731
     3732
    18673733        wp_die();
    18683734
    18693735
     3736
     3737
     3738
    18703739    }
    18713740
    18723741
     3742
     3743
     3744
    18733745    function remove_post_meta_condition()
    18743746
     3747
     3748
    18753749    {
    18763750
     3751
     3752
    18773753        // echo $_GET['meta_ids'];
    18783754
     3755
     3756
    18793757        global $wpdb;
    18803758
     3759
     3760
    18813761        $table_name = $wpdb->prefix . "postmeta";
    18823762
     3763
     3764
    18833765        $wpdb->get_var("DELETE FROM " . $table_name . " where meta_id IN (" . $_GET['meta_ids'] . ")");
    18843766
     3767
     3768
    18853769        echo "Post Meta Setting Deleted Successfully";
    18863770
     3771
     3772
    18873773        wp_die();
    18883774
    18893775
     3776
     3777
     3778
    18903779    }
    18913780
     3781
     3782
    18923783    function activation_updated()
    18933784
     3785
     3786
    18943787    {
    18953788
     3789
     3790
    18963791        $post_id = $_REQUEST['meta_ids'];
    18973792
     3793
     3794
    18983795        global $wpdb;
    18993796
     3797
     3798
    19003799        $tablename = $wpdb->prefix . "postmeta";
    19013800
     3801
     3802
    19023803        $status = $_REQUEST['status'];
    19033804
     3805
     3806
    19043807        echo $sql = "UPDATE `$tablename` SET `meta_value`='" . $status . "' WHERE meta_key = 'activation' AND post_id =" . $post_id;
    19053808
     3809
     3810
    19063811        $wpdb->query($wpdb->prepare($sql));
    19073812
     3813
     3814
    19083815        echo 'data updated';
    19093816
     3817
     3818
    19103819        wp_die();
    19113820
    19123821
     3822
     3823
     3824
    19133825    }
    19143826
     3827
     3828
    19153829    function add_new_columns($columns)
     3830
    19163831    {
     3832
    19173833        return array_merge($columns,
    19183834
     3835
     3836
    19193837            array('type' => __('Status'),
    19203838
     3839
     3840
    19213841                'condition' => __('Condition')));
    19223842
     3843
     3844
    19233845    }
    19243846
     3847
     3848
    19253849    function custom_column_data($column)
     3850
    19263851    {
    19273852
     3853
     3854
    19283855        global $post;
     3856
    19293857        global $p_count;
     3858
    19303859        $p_count++;
     3860
    19313861        //$c = count1(0);
     3862
    19323863        //echo '<pre>$Count'. $p_count++ .'</pre>';
     3864
    19333865        if ($column == 'type' && $p_count % 2 == 0) {
     3866
    19343867            $activation = get_post_meta($post->ID, 'activation', true);
     3868
    19353869            echo '<span class="master-status master-status-' . ($activation == 'yes' ? 'active' : 'inactive') . '">' . ($activation == 'yes' ? 'Active' : 'Inactive') . '</span>';
     3870
    19363871            $p_count++;
    19373872
     3873
     3874
    19383875        } elseif ($column == 'condition' && $p_count % 2 != 0) {
     3876
    19393877            $conditionCounter = get_post_meta($post->ID, 'counterCondition', true);
    19403878
     3879
     3880
    19413881            for ($index = 1; $index <= $conditionCounter; $index++) {
    19423882
     3883
     3884
    19433885                echo $condition_a = get_post_meta($post->ID, 'condition_a' . $index, true);
    19443886
     3887
     3888
    19453889                $condition_singular = get_post_meta($post->ID, 'condition_singular' . $index, true);
    19463890
     3891
     3892
    19473893                if ($condition_a == 'singular') {
    19483894
     3895
     3896
    19493897                    echo ' > ' . $condition_singular;
    19503898
     3899
     3900
    19513901                }
    19523902
     3903
     3904
    19533905                if ($condition_singular == 'selective') {
    19543906
     3907
     3908
    19553909                    print_r(' > ' . implode(',', get_post_meta($post->ID, 'condition_singular_id' . $index, true)));
    19563910
     3911
     3912
    19573913                }
    19583914
     3915
     3916
    19593917                echo '<br>';
    19603918
     3919
     3920
    19613921            }
     3922
    19623923            $p_count++;
    19633924
    19643925
     3926
     3927
     3928
    19653929        }
     3930
    19663931        /* switch ($column) {
    19673932
     3933
     3934
    19683935             case 'type':
    19693936
     3937
     3938
    19703939                 //echo get_post_meta($post->ID, 'type', true);
     3940
    19713941                 $activation = get_post_meta($post->ID, 'activation', true);
     3942
    19723943                 echo '<span id = " '. $c . ' " class="master-status master-status-' . ($activation == 'yes' ? 'active' : 'inactive') . '">' . ($activation == 'yes' ? 'Active' : 'Inactive') . '</span>';
    19733944
     3945
     3946
    19743947                 break;
    19753948
     3949
     3950
    19763951             case 'condition':
    19773952
     3953
     3954
    19783955                 //echo get_post_meta( $post->ID , 'c' , true );
    19793956
     3957
     3958
    19803959                 $conditionCounter = get_post_meta($post->ID, 'counterCondition', true);
    19813960
     3961
     3962
    19823963                 for ($index = 1; $index <= $conditionCounter; $index++) {
    19833964
     3965
     3966
    19843967                     echo $condition_a = get_post_meta($post->ID, 'condition_a' . $index, true);
    19853968
     3969
     3970
    19863971                     $condition_singular = get_post_meta($post->ID, 'condition_singular' . $index, true);
    19873972
     3973
     3974
    19883975                     if ($condition_a == 'singular') {
    19893976
     3977
     3978
    19903979                         echo ' > ' . $condition_singular;
    19913980
     3981
     3982
    19923983                     }
    19933984
     3985
     3986
    19943987                     if ($condition_singular == 'selective') {
    19953988
     3989
     3990
    19963991                         print_r(' > ' . implode(',', get_post_meta($post->ID, 'condition_singular_id' . $index, true)));
    19973992
     3993
     3994
    19983995                     }
    19993996
     3997
     3998
    20003999                     echo '<br>';
    20014000
     4001
     4002
    20024003                 }
    20034004
    20044005
     4006
     4007
     4008
    20054009                 break;
    20064010
     4011
     4012
    20074013         }*/
    20084014
     4015
     4016
    20094017    }
    20104018
     4019
     4020
    20114021    function check_module_active()
     4022
    20124023    {
     4024
    20134025        global $wpdb;
     4026
    20144027        $table_name = $wpdb->prefix . "me_settings";
     4028
    20154029        $result = $wpdb->get_row("SELECT * FROM " . $table_name . " where name='" . $_GET['module'] . "'");
     4030
    20164031        $status = ($result->value == 'yes') ? 'yes' : 'no';
     4032
    20174033        echo $status;
     4034
    20184035        die;
     4036
    20194037    }
    20204038
     4039
     4040
    20214041    function get_menu_template()
     4042
    20224043    {
     4044
    20234045        global $wpdb;
     4046
    20244047        $table_name = $wpdb->prefix . "posts";
     4048
    20254049             $postslist = $wpdb->get_results (
     4050
    20264051                        " SELECT * FROM  " . $table_name ."  WHERE post_type =  'me_megamenu' AND post_status = 'publish' ORDER by post_title " );
     4052
    20274053        $data = array();
     4054
    20284055        foreach ($postslist as $key => $post) {
     4056
    20294057                $menu = explode('menu-item-', $_GET['menu']);
    2030                 $result = $wpdb->get_row("SELECT * FROM " . $table_name . " where post_id='" . $menu[1] . "'" . " AND meta_value='" . $post->ID . "'");
     4058
    20314059                $data[$key]['ID'] = $post->ID;
     4060
    20324061                $data[$key]['post_title'] = $post->post_title;
    2033                 $data[$key]['menu_item'] = $result->post_id;
     4062               
    20344063        }
     4064
    20354065        echo json_encode($data, true);
     4066
    20364067        die;
     4068
    20374069    }
    20384070
     4071
     4072
    20394073    function save_menu_postmeta()
     4074
    20404075    {
     4076
    20414077        $menu = explode('menu-item-', $_POST['menu_id']);
     4078
    20424079        if (get_post_meta($menu[1])) {
     4080
    20434081            update_post_meta($menu[1], 'me_megamenu_item', $_POST['megamenu_id']);
     4082
    20444083        } else {
     4084
    20454085            add_post_meta($menu[1], 'me_megamenu_item', $_POST['megamenu_id']);
     4086
    20464087        }
     4088
    20474089        die;
     4090
    20484091    }
    20494092
     4093
     4094
    20504095    function get_megamenu_control()
     4096
    20514097    {
     4098
    20524099        global $wpdb;
     4100
    20534101        $table_name = $wpdb->prefix . "me_settings";
     4102
    20544103        $menu = $wpdb->get_row("SELECT * FROM " . $table_name . " where name='" . $_GET['menu'] . "'");
     4104
    20554105        echo json_encode($menu, true);
     4106
    20564107        die;
     4108
    20574109    }
    20584110
     4111
     4112
    20594113    function demo_data_import()
     4114
    20604115    {
     4116
    20614117        if ($_POST['url'] && $_POST['post_type']) {
     4118
    20624119            $api = new Api();
     4120
    20634121            $api->render_widget($_POST['url'], $_POST['post_type']);
     4122
    20644123        }
     4124
    20654125        die;
     4126
    20664127    }
    20674128
     4129
     4130
    20684131    function get_cat_data()
     4132
    20694133    {
     4134
    20704135        $categoryTemplates = [];
     4136
    20714137        if (isset($_POST['category'])) {
     4138
    20724139            $demo_data_listing_url = 'http://demo.designingmedia.com/master-demo/template-categories.json';
     4140
    20734141            $data = file_get_contents($demo_data_listing_url);
     4142
    20744143            $data = json_decode($data);
    20754144
     4145
     4146
    20764147            foreach ($data as $k => $d) {
     4148
    20774149                if ($k == $_POST['category']) {
     4150
    20784151                    $categoryTemplates = $d;
     4152
    20794153                }
     4154
    20804155            }
     4156
    20814157        }
    20824158
     4159
     4160
    20834161        echo json_encode($categoryTemplates, true);
     4162
    20844163        die;
     4164
    20854165    }
    20864166
     4167
     4168
    20874169    function send_feedback()
     4170
    20884171    {
     4172
    20894173        //user posted variables
     4174
    20904175        $name = $_POST['name'];
     4176
    20914177        $email = $_POST['email'];
     4178
    20924179        $website = $_POST['website'];
     4180
    20934181        $comment = $_POST['comment'];
    20944182
     4183
     4184
    20954185        //php mailer variables
     4186
    20964187        $to = get_option('admin_email');
     4188
    20974189        $subject = "Masterelement Feedback";
     4190
    20984191        $headers = 'From: ' . $email . "\r\n" .
     4192
    20994193            'Reply-To: ' . $email . "\r\n";
    21004194
     4195
     4196
    21014197        $body = 'Name: ' . $name . "\r\n" .
     4198
    21024199            'Email: ' . $email . "\r\n" .
     4200
    21034201            'Website: ' . $website . "\r\n" .
     4202
    21044203            'Message: ' . $comment . "\r\n";
    21054204
     4205
     4206
    21064207        //Here put your Validation and send mail
     4208
    21074209        $sent = wp_mail($to, $subject, strip_tags($body), $headers);
     4210
    21084211        if ($sent) {
     4212
    21094213            echo 'Sent';
     4214
    21104215        }//message sent!
     4216
    21114217        else {
     4218
    21124219            echo 'Not Sent';
     4220
    21134221        }//message wasn't sent
    21144222
     4223
     4224
    21154225        die;
     4226
    21164227    }
    21174228
     4229
     4230
    21184231    function custom_submit_form()
     4232
    21194233    {
     4234
    21204235        $body = '';
     4236
    21214237        if ($_POST['fileds']) {
     4238
    21224239            $fields = explode('&', $_POST['fileds']);
     4240
    21234241            foreach ($fields as $k => $v) {
     4242
    21244243                if ($v !== 'form_id=2fad637') {
     4244
    21254245                    $body = ' ' . $v . "\r\n";
     4246
    21264247                }
     4248
    21274249            }
     4250
    21284251        }
    21294252
     4253
     4254
    21304255        wp_mail(get_option('admin_email'), 'Contact Query', $body);
     4256
    21314257        wp_send_json_success(__('Thanks for reporting !', 'masterelements'));
     4258
    21324259        wp_die();
     4260
    21334261    }
    21344262
     4263
     4264
    21354265}
    21364266
    21374267
     4268
     4269
     4270
    21384271new Master_Custom_Post();
Note: See TracChangeset for help on using the changeset viewer.