import
5 days ago
includes
5 days ago
metabox
5 days ago
notices
5 days ago
templates
5 days ago
mega-menu.php
5 days ago
plugin-options.php
5 days ago
popups.php
5 days ago
premade-blocks.php
5 days ago
templates-kit.php
5 days ago
theme-builder.php
5 days ago
theme-builder.php
194 lines
| 1 | <?php |
| 2 | |
| 3 | if ( ! defined( 'ABSPATH' ) ) { |
| 4 | exit; // Exit if accessed directly. |
| 5 | } |
| 6 | |
| 7 | use WprAddons\Admin\Includes\WPR_Templates_Loop; |
| 8 | use WprAddons\Classes\Utilities; |
| 9 | |
| 10 | // Register Menus |
| 11 | function wpr_addons_add_theme_builder_menu() { |
| 12 | add_submenu_page( 'wpr-addons', 'Theme Builder', 'Theme Builder', 'manage_options', 'wpr-theme-builder', 'wpr_addons_theme_builder_page' ); |
| 13 | } |
| 14 | add_action( 'admin_menu', 'wpr_addons_add_theme_builder_menu' ); |
| 15 | |
| 16 | function wpr_addons_theme_builder_page() { |
| 17 | |
| 18 | ?> |
| 19 | |
| 20 | <div class="wrap wpr-settings-page-wrap"> |
| 21 | |
| 22 | <div class="wpr-settings-page-header"> |
| 23 | <h1><?php echo esc_html(Utilities::get_plugin_name(true)); ?></h1> |
| 24 | |
| 25 | <p><?php esc_html_e( 'The most powerful Elementor Addon in the universe.', 'wpr-addons' ); ?></p> |
| 26 | <!-- <a href="https://royaladdons.frill.co/b/6m4d5qm4/feature-ideas" class="" target="_blank" style="padding: 8px 22px;"> |
| 27 | <?php echo esc_html__( 'Request New Feature', 'wpr-addons' ); ?> |
| 28 | </a> --> |
| 29 | |
| 30 | <!-- Custom Template --> |
| 31 | <div class="wpr-preview-buttons"> |
| 32 | <div class="wpr-user-template"> |
| 33 | <span><?php esc_html_e( 'Create Template', 'wpr-addons' ); ?></span> |
| 34 | <span class="plus-icon">+</span> |
| 35 | |
| 36 | <?php |
| 37 | if ( ! class_exists( 'WooCommerce' ) && isset($_GET['tab']) && ('wpr_tab_product_archive' === $_GET['tab'] || 'wpr_tab_product_single' === $_GET['tab'] )) { |
| 38 | echo '<div></div>'; |
| 39 | } |
| 40 | ?> |
| 41 | </div> |
| 42 | |
| 43 | <a href="https://www.youtube.com/watch?v=cwkhwO_rPuo" class="wpr-how-to-use-theme-builder wpr-options-button button" target="_blank"> |
| 44 | <?php echo esc_html__( 'Theme Builder Tutorial', 'wpr-addons' ); ?> |
| 45 | <span class="dashicons dashicons-video-alt3"></span> |
| 46 | </a> |
| 47 | |
| 48 | <a href="https://www.youtube.com/watch?v=f_3tNiBC3dw" class="wpr-how-to-use-woo-builder wpr-options-button button" target="_blank"> |
| 49 | <?php echo esc_html__( 'WooCommerce Builder Tutorial', 'wpr-addons' ); ?> |
| 50 | <span class="dashicons dashicons-video-alt3"></span> |
| 51 | </a> |
| 52 | |
| 53 | <a href="https://www.youtube.com/watch?v=kE1zmi3fxh8" class="wpr-dynamic-tutorial wpr-options-button button" target="_blank"> |
| 54 | <?php echo esc_html__( 'Dynamic Websites Tutorial', 'wpr-addons' ); ?> |
| 55 | <span class="dashicons dashicons-video-alt3"></span> |
| 56 | </a> |
| 57 | </div> |
| 58 | </div> |
| 59 | |
| 60 | <div class="wpr-settings-page"> |
| 61 | <form method="post" action="options.php"> |
| 62 | <?php |
| 63 | |
| 64 | // Active Tab |
| 65 | $active_tab = isset( $_GET['tab'] ) ? sanitize_text_field( wp_unslash( $_GET['tab'] ) ) : 'wpr_tab_header'; |
| 66 | |
| 67 | ?> |
| 68 | |
| 69 | <!-- Template ID Holder --> |
| 70 | <input type="hidden" name="wpr_template" id="wpr_template" value=""> |
| 71 | |
| 72 | <!-- Conditions Popup --> |
| 73 | <?php WPR_Templates_Loop::render_conditions_popup(true); ?> |
| 74 | |
| 75 | <!-- Create Templte Popup --> |
| 76 | <?php WPR_Templates_Loop::render_create_template_popup(); ?> |
| 77 | |
| 78 | <!-- Backup Plugin Popup --> |
| 79 | <?php WPR_Templates_Loop::render_backup_plugin_popup(); ?> |
| 80 | |
| 81 | <!-- Tabs --> |
| 82 | <div class="nav-tab-wrapper wpr-nav-tab-wrapper"> |
| 83 | <a href="?page=wpr-theme-builder&tab=wpr_tab_header" data-title="Header" class="nav-tab <?php echo ($active_tab == 'wpr_tab_header') ? 'nav-tab-active' : ''; ?>"> |
| 84 | <?php esc_html_e( 'Header', 'wpr-addons' ); ?> |
| 85 | </a> |
| 86 | <a href="?page=wpr-theme-builder&tab=wpr_tab_footer" data-title="Footer" class="nav-tab <?php echo ($active_tab == 'wpr_tab_footer') ? 'nav-tab-active' : ''; ?>"> |
| 87 | <?php esc_html_e( 'Footer', 'wpr-addons' ); ?> |
| 88 | </a> |
| 89 | <a href="?page=wpr-theme-builder&tab=wpr_tab_archive" data-title="Archive" class="nav-tab <?php echo ($active_tab == 'wpr_tab_archive') ? 'nav-tab-active' : ''; ?>"> |
| 90 | <?php esc_html_e( 'Archive', 'wpr-addons' ); ?> |
| 91 | </a> |
| 92 | <a href="?page=wpr-theme-builder&tab=wpr_tab_single" data-title="Single" class="nav-tab <?php echo ($active_tab == 'wpr_tab_single') ? 'nav-tab-active' : ''; ?>"> |
| 93 | <?php esc_html_e( 'Single', 'wpr-addons' ); ?> |
| 94 | </a> |
| 95 | |
| 96 | <a href="?page=wpr-theme-builder&tab=wpr_tab_product_archive" data-title="Product Archive" class="nav-tab <?php echo $active_tab == 'wpr_tab_product_archive' ? 'nav-tab-active' : ''; ?>"> |
| 97 | <?php esc_html_e( 'Product Archive', 'wpr-addons' ); ?> |
| 98 | </a> |
| 99 | <a href="?page=wpr-theme-builder&tab=wpr_tab_product_single" data-title="Product Single" class="nav-tab <?php echo $active_tab == 'wpr_tab_product_single' ? 'nav-tab-active' : ''; ?>"> |
| 100 | <?php esc_html_e( 'Product Single', 'wpr-addons' ); ?> |
| 101 | </a> |
| 102 | |
| 103 | <a href="?page=wpr-theme-builder&tab=wpr_tab_my_templates" data-title="My Templates" class="nav-tab <?php echo ($active_tab == 'wpr_tab_my_templates') ? 'nav-tab-active' : ''; ?>"> |
| 104 | <?php esc_html_e( 'Saved Templates', 'wpr-addons' ); ?> |
| 105 | </a> |
| 106 | </div> |
| 107 | |
| 108 | |
| 109 | <?php |
| 110 | if ( is_plugin_active( 'sitepress-multilingual-cms/sitepress.php' ) ) { |
| 111 | $url = ''; |
| 112 | if ( 'wpr_tab_my_templates' === $active_tab ) { |
| 113 | $url = admin_url( 'edit.php?post_type=elementor_library&tabs_group=library' ); |
| 114 | } else { |
| 115 | $url = admin_url( 'edit.php?s&post_status=all&post_type=wpr_templates&wpr_template_type='. str_replace("wpr_tab_", "", $active_tab) .'&filter_action=Filter' ); |
| 116 | } |
| 117 | echo '<a href="' . esc_url( $url ) . '" class="button button-primary wpr-translate-templates wpr-options-button"><span class="dashicons dashicons-admin-site"></span><span>Translate WPML Templates</span></a>'; |
| 118 | echo '<a href="https://www.youtube.com/watch?v=y7yjItsMBmw" class="button button-primary wpr-translate-templates wpr-options-button tutorial">'. esc_html__("Video Tutorial") .'</a>'; |
| 119 | } else if ( is_plugin_active('polylang/polylang.php') ) { |
| 120 | $url = ''; |
| 121 | if ( 'wpr_tab_my_templates' === $active_tab ) { |
| 122 | $url = admin_url( 'edit.php?post_type=elementor_library&tabs_group=library' ); |
| 123 | } else { |
| 124 | $url = admin_url( 'edit.php?s&post_status=all&post_type=wpr_templates&wpr_template_type='. str_replace("wpr_tab_", "", $active_tab) .'&filter_action=Filter' ); |
| 125 | } |
| 126 | echo '<a href="' . esc_url( $url ) . '" class="button button-primary wpr-translate-templates wpr-options-button"><span class="dashicons dashicons-admin-site"></span><span>Translate POLYLANG Templates</span></a>'; |
| 127 | echo '<a href="https://www.youtube.com/watch?v=y7yjItsMBmw" class="button button-primary wpr-translate-templates wpr-options-button tutorial">'. esc_html__("Video Tutorial") .'</a>'; |
| 128 | } |
| 129 | ?> |
| 130 | <?php if ( $active_tab == 'wpr_tab_header' ) : ?> |
| 131 | |
| 132 | <!-- Save Conditions --> |
| 133 | <input type="hidden" name="wpr_header_conditions" id="wpr_header_conditions" value="<?php echo esc_attr(get_option('wpr_header_conditions', '[]')); ?>"> |
| 134 | |
| 135 | <?php WPR_Templates_Loop::render_theme_builder_templates( 'header' ); ?> |
| 136 | |
| 137 | <?php elseif ( $active_tab == 'wpr_tab_footer' ) : ?> |
| 138 | |
| 139 | <!-- Save Conditions --> |
| 140 | <input type="hidden" name="wpr_footer_conditions" id="wpr_footer_conditions" value="<?php echo esc_attr(get_option('wpr_footer_conditions', '[]')); ?>"> |
| 141 | |
| 142 | <?php WPR_Templates_Loop::render_theme_builder_templates( 'footer' ); ?> |
| 143 | |
| 144 | <?php elseif ( $active_tab == 'wpr_tab_archive' ) : ?> |
| 145 | |
| 146 | <!-- Save Conditions --> |
| 147 | <input type="hidden" name="wpr_archive_conditions" id="wpr_archive_conditions" value="<?php echo esc_attr(get_option('wpr_archive_conditions', '[]')); ?>"> |
| 148 | |
| 149 | <?php WPR_Templates_Loop::render_theme_builder_templates( 'archive' ); ?> |
| 150 | |
| 151 | <?php elseif ( $active_tab == 'wpr_tab_single' ) : ?> |
| 152 | |
| 153 | <!-- Save Conditions --> |
| 154 | <input type="hidden" name="wpr_single_conditions" id="wpr_single_conditions" value="<?php echo esc_attr(get_option('wpr_single_conditions', '[]')); ?>"> |
| 155 | |
| 156 | <?php WPR_Templates_Loop::render_theme_builder_templates( 'single' ); ?> |
| 157 | |
| 158 | <?php elseif ( $active_tab == 'wpr_tab_product_archive' ) : ?> |
| 159 | |
| 160 | <?php if ( class_exists( 'WooCommerce' ) ) : ?> |
| 161 | <!-- Save Conditions --> |
| 162 | <input type="hidden" name="wpr_product_archive_conditions" id="wpr_product_archive_conditions" value="<?php echo esc_attr(get_option('wpr_product_archive_conditions', '[]')); ?>"> |
| 163 | |
| 164 | <?php WPR_Templates_Loop::render_theme_builder_templates( 'product_archive' ); ?> |
| 165 | <?php else : ?> |
| 166 | <div class="wpr-activate-woo-notice"><span class="dashicons dashicons-info-outline"></span> Please install/activate WooCommerce in order to create product archive templates!</div> |
| 167 | <?php endif; ?> |
| 168 | |
| 169 | <?php elseif ( $active_tab == 'wpr_tab_product_single' ) : ?> |
| 170 | |
| 171 | <?php if ( class_exists( 'WooCommerce' ) ) : ?> |
| 172 | <!-- Save Conditions --> |
| 173 | <input type="hidden" name="wpr_product_single_conditions" id="wpr_product_single_conditions" value="<?php echo esc_attr(get_option('wpr_product_single_conditions', '[]')); ?>"> |
| 174 | |
| 175 | <?php WPR_Templates_Loop::render_theme_builder_templates( 'product_single' ); ?> |
| 176 | <?php else : ?> |
| 177 | <div class="wpr-activate-woo-notice"><span class="dashicons dashicons-info-outline"></span> Please install/activate WooCommerce in order to create product single templates!</div> |
| 178 | <?php endif ; ?> |
| 179 | |
| 180 | <?php elseif ( $active_tab == 'wpr_tab_my_templates' ) : ?> |
| 181 | |
| 182 | <?php Wpr_Templates_Loop::render_elementor_saved_templates(); ?> |
| 183 | |
| 184 | <?php endif; ?> |
| 185 | |
| 186 | </form> |
| 187 | </div> |
| 188 | |
| 189 | </div> |
| 190 | |
| 191 | |
| 192 | <?php |
| 193 | |
| 194 | } // End wpr_addons_theme_builder_page() |