admin.php
557 lines
| 1 | <?php |
| 2 | /* |
| 3 | Class Name: VI_WOO_BOPO_BUNDLE_Admin |
| 4 | Author: Andy Ha (support@villatheme.com) |
| 5 | Author URI: http://villatheme.com |
| 6 | Copyright 2022-2026 VillaTheme.com. All rights reserved. |
| 7 | */ |
| 8 | if ( ! defined( 'ABSPATH' ) ) { |
| 9 | exit; |
| 10 | } |
| 11 | |
| 12 | class VI_WOO_BOPO_BUNDLE_Admin { |
| 13 | protected $settings; |
| 14 | protected $language; |
| 15 | protected $languages; |
| 16 | protected $default_language; |
| 17 | protected $languages_data; |
| 18 | protected $languages_count; |
| 19 | |
| 20 | function __construct() { |
| 21 | register_activation_hook( __FILE__, array( $this, 'install' ) ); |
| 22 | $this->settings = VI_WOO_BOPO_BUNDLE_DATA::get_instance(); |
| 23 | $this->languages = array(); |
| 24 | $this->languages_count = 0; |
| 25 | $this->languages_data = array(); |
| 26 | $this->default_language = ''; |
| 27 | add_filter( |
| 28 | 'plugin_action_links_bopo-woo-product-bundle-builder/bopo-woo-product-bundle-builder.php', array( |
| 29 | $this, |
| 30 | 'settings_link' |
| 31 | ) |
| 32 | ); |
| 33 | add_action( 'init', array( $this, 'init' ) ); |
| 34 | add_action( 'admin_menu', array( $this, 'add_menu' ) ); |
| 35 | add_action( 'admin_init', array( $this, 'save_settings' ), 99 ); |
| 36 | |
| 37 | add_action( 'wp_ajax_bopobb_first_bopobb_link', array( $this, 'bopobb_first_bopobb_link' ) ); |
| 38 | |
| 39 | add_action( 'wp_print_scripts', array( $this, 'custom_script' ) ); |
| 40 | |
| 41 | add_action( 'admin_enqueue_scripts', array( $this, 'admin_enqueue_script' ) ); |
| 42 | |
| 43 | } |
| 44 | |
| 45 | function init() { |
| 46 | bopobb_register_product_type(); |
| 47 | load_plugin_textdomain( 'woo-bopo-bundle' ); |
| 48 | $this->load_plugin_textDomain(); |
| 49 | if ( class_exists( 'VillaTheme_Support' ) ) { |
| 50 | new VillaTheme_Support( |
| 51 | array( |
| 52 | 'support' => 'https://wordpress.org/support/plugin/bopo-woo-product-bundle-builder/', |
| 53 | 'docs' => 'https://docs.villatheme.com/?item=bopo', |
| 54 | 'review' => 'https://wordpress.org/plugins/bopo-woo-product-bundle-builder/#reviews/?rate=5#rate-response', |
| 55 | 'pro_url' => 'https://1.envato.market/4eLB0L', |
| 56 | 'css' => VI_WOO_BOPO_BUNDLE_CSS, |
| 57 | 'image' => VI_WOO_BOPO_BUNDLE_IMAGES, |
| 58 | 'slug' => 'bopo-woo-product-bundle-builder', |
| 59 | 'menu_slug' => 'bopo-woo-product-bundle-builder', |
| 60 | 'survey_url' => 'https://script.google.com/macros/s/AKfycbwx2ZKrkb5qi_M8sq3jin3vcJ7QTj6TcHzfWVNmo_G8Jz5ExtXOOboaoi06RN_6Jx-a/exec', |
| 61 | 'version' => VI_WOO_BOPO_BUNDLE_VERSION |
| 62 | ) |
| 63 | ); |
| 64 | } |
| 65 | } |
| 66 | |
| 67 | /** |
| 68 | * load Language translate |
| 69 | */ |
| 70 | function load_plugin_textDomain() { |
| 71 | $locale = apply_filters( 'plugin_locale', get_locale(), 'woo-bopo-bundle' ); |
| 72 | // Admin Locale |
| 73 | if ( is_admin() ) { |
| 74 | load_textdomain( 'woo-bopo-bundle', VI_WOO_BOPO_BUNDLE_LANGUAGES . "woo-bopo-bundle-$locale.mo" ); |
| 75 | } |
| 76 | |
| 77 | // Global + Frontend Locale |
| 78 | load_textdomain( 'woo-bopo-bundle', VI_WOO_BOPO_BUNDLE_LANGUAGES . "woo-bopo-bundle-$locale.mo" ); |
| 79 | load_plugin_textdomain( 'woo-bopo-bundle', false, VI_WOO_BOPO_BUNDLE_LANGUAGES ); |
| 80 | } |
| 81 | |
| 82 | /** |
| 83 | * When active plugin Function will be call |
| 84 | */ |
| 85 | public function install() { |
| 86 | global $wp_version; |
| 87 | If ( version_compare( $wp_version, "2.9", "<" ) ) { |
| 88 | deactivate_plugins( basename( __FILE__ ) ); // Deactivate our plugin |
| 89 | wp_die( "This plugin requires WordPress version 2.9 or higher." ); |
| 90 | } |
| 91 | } |
| 92 | |
| 93 | function add_menu() { |
| 94 | add_menu_page( |
| 95 | esc_html__( 'Bopo - Woo product bundle builder', 'woo-bopo-bundle' ), |
| 96 | esc_html__( 'Bopo Bundle', 'woo-bopo-bundle' ), |
| 97 | 'manage_options', |
| 98 | 'woo-bopo-bundle', |
| 99 | array( |
| 100 | $this, |
| 101 | 'settings_page' |
| 102 | ), VI_WOO_BOPO_BUNDLE_IMAGES . 'icon_bopo.svg', 2 |
| 103 | ); |
| 104 | add_submenu_page( |
| 105 | 'woo-bopo-bundle', |
| 106 | esc_html__( 'Bopo - Woo Product Bundle Builder', 'woo-bopo-bundle' ), |
| 107 | esc_html__( 'Settings', 'woo-bopo-bundle' ), |
| 108 | 'manage_options', |
| 109 | 'woo-bopo-bundle' |
| 110 | ); |
| 111 | } |
| 112 | |
| 113 | public function custom_script() { |
| 114 | $script = 'var bopobb_ajax_url = "' . esc_url( admin_url( 'admin-ajax.php' ) ) . '"'; ?> |
| 115 | <script type="text/javascript" data-cfasync="false"> |
| 116 | <?php echo $script;// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?> |
| 117 | </script> |
| 118 | <?php } |
| 119 | |
| 120 | public function bopobb_first_bopobb_link() { |
| 121 | if ( ! current_user_can( 'manage_options' ) ) { |
| 122 | wp_die(); |
| 123 | } |
| 124 | check_ajax_referer( 'bopobb_settings_page_save', 'nonce' ); |
| 125 | $bopo_settings['bopobb-first-product'] = 1; |
| 126 | update_option( 'woo_bopo_bundle_params', $bopo_settings ); |
| 127 | wp_die(); |
| 128 | } |
| 129 | |
| 130 | function bopobb_wp_get_page_url_by_template_slug( $template_slug ) { |
| 131 | $url = null; |
| 132 | $template = 'page-' . $template_slug . '.php'; |
| 133 | |
| 134 | $pages = get_posts( array( |
| 135 | 'post_type' => 'page', |
| 136 | 'meta_query' => array(// phpcs:ignore WordPress.DB.SlowDBQuery.slow_db_query_meta_query |
| 137 | array( |
| 138 | 'key' => '_wp_page_template', |
| 139 | 'value' => $template, |
| 140 | 'compare' => '=', |
| 141 | ) |
| 142 | ) |
| 143 | ) ); |
| 144 | |
| 145 | if ( isset( $pages[0] ) ) { |
| 146 | $url = get_permalink( $pages[0]->ID ); |
| 147 | } |
| 148 | |
| 149 | return $url; |
| 150 | } |
| 151 | |
| 152 | /** |
| 153 | * Save data. |
| 154 | */ |
| 155 | public function save_settings() { |
| 156 | global $bopobb_settings; |
| 157 | if ( ! current_user_can( 'manage_options' ) ) { |
| 158 | return; |
| 159 | } |
| 160 | if ( ! isset( $_POST['bopobb_nonce_field'] ) || ! wp_verify_nonce( $_POST['bopobb_nonce_field'], 'bopobb_settings_page_save' ) ) { |
| 161 | return; |
| 162 | } |
| 163 | |
| 164 | /*wpml*/ |
| 165 | if ( is_plugin_active( 'sitepress-multilingual-cms/sitepress.php' ) ) { |
| 166 | global $sitepress; |
| 167 | $default_lang = $sitepress->get_default_language(); |
| 168 | $this->default_language = $default_lang; |
| 169 | $languages = icl_get_languages( 'skip_missing=N&orderby=KEY&order=DIR&link_empty_to=str' ); |
| 170 | $this->languages_data = $languages; |
| 171 | if ( count( $languages ) ) { |
| 172 | foreach ( $languages as $key => $language ) { |
| 173 | if ( $key != $default_lang ) { |
| 174 | $this->languages[] = $key; |
| 175 | } |
| 176 | } |
| 177 | } |
| 178 | } elseif ( class_exists( 'Polylang' ) ) { |
| 179 | /*Polylang*/ |
| 180 | $languages = pll_languages_list(); |
| 181 | $default_lang = pll_default_language( 'slug' ); |
| 182 | foreach ( $languages as $language ) { |
| 183 | if ( $language == $default_lang ) { |
| 184 | continue; |
| 185 | } |
| 186 | $this->languages[] = $language; |
| 187 | } |
| 188 | } |
| 189 | $this->languages_count = count( $this->languages ); |
| 190 | |
| 191 | $args = array( |
| 192 | //General |
| 193 | 'bopobb_view_quantity' => 0, |
| 194 | 'bopobb_view_stock' => 0, |
| 195 | 'bopobb_view_ratting' => 0, |
| 196 | 'bopobb_view_description' => 0, |
| 197 | 'bopobb_link_individual' => 0, |
| 198 | 'bopobb_single_template' => 1, |
| 199 | |
| 200 | //swap button |
| 201 | 'bopobb_swap_text' => 'Change', |
| 202 | 'bopobb_swap_pos' => 1, |
| 203 | 'bopobb_swap_background' => '', |
| 204 | 'bopobb_swap_color' => '', |
| 205 | |
| 206 | //popup |
| 207 | 'bopobb_popup_title' => 'Select product to bundle', |
| 208 | 'bopobb_popup_background' => '', |
| 209 | 'bopobb_popup_color' => '', |
| 210 | 'bopobb_popup_fontsize' => '', |
| 211 | 'bopobb_popup_page_items' => 32, |
| 212 | ); |
| 213 | if ( $this->languages_count ) { |
| 214 | foreach ( $this->languages as $key => $value ) { |
| 215 | // $args[ 'bopobb_swap_text_' . $value ] = isset( $_POST[ 'bopobb_swap_text_' . $value ] ) ? sanitize_text_field( $_POST[ 'bopobb_swap_text_' . $value ] ) : 'Change'; |
| 216 | $args[ 'bopobb_popup_title_' . $value ] = isset( $_POST[ 'bopobb_popup_title_' . $value ] ) ? sanitize_text_field( $_POST[ 'bopobb_popup_title_' . $value ] ) : 'Select product to bundle'; |
| 217 | } |
| 218 | } |
| 219 | foreach ( $args as $key => $arg ) { |
| 220 | $args[ $key ] = isset( $_POST[ $key ] ) ? sanitize_text_field( $_POST[ $key ] ) : ''; |
| 221 | } |
| 222 | $args = wp_parse_args( $args, get_option( 'woo_bopo_bundle_params', $bopobb_settings ) ); |
| 223 | update_option( 'woo_bopo_bundle_params', $args ); |
| 224 | $bopobb_settings = $args; |
| 225 | $this->settings = VI_WOO_BOPO_BUNDLE_DATA::get_instance( true ); |
| 226 | add_action( 'admin_notices', function () { |
| 227 | ?> |
| 228 | <div class="updated"> |
| 229 | <p><?php esc_html_e( 'Your settings have been saved!', 'woo-bopo-bundle' ) ?></p> |
| 230 | </div> |
| 231 | <?php |
| 232 | } ); |
| 233 | } |
| 234 | |
| 235 | public function settings_page() { |
| 236 | if ( ! current_user_can( 'manage_options' ) ) { |
| 237 | return; |
| 238 | } |
| 239 | ?> |
| 240 | <div class="wrap"> |
| 241 | <h2><?php esc_html_e( 'Bopo - Woo Product Bundle Builder - Build Your Own Box', 'woo-bopo-bundle' ); ?></h2> |
| 242 | <div class="vi-ui raised"> |
| 243 | <form class="vi-ui form bopobb-general-settings" method="post" action=""> |
| 244 | <?php |
| 245 | wp_nonce_field( 'bopobb_settings_page_save', 'bopobb_nonce_field' ); |
| 246 | ?> |
| 247 | <div class="vi-ui segment"> |
| 248 | <table class="vi-ui bottom attached form-table"> |
| 249 | <tbody> |
| 250 | <?php if ( $this->settings->get_params( 'bopobb-first-product' ) == 0 ) { ?> |
| 251 | <h5 class="vi-ui label"><?php esc_html_e( 'Create your first bopo product: ', 'woo-bopo-bundle' ); ?> |
| 252 | <a class="bopobb-create-product" |
| 253 | href="<?php echo esc_url( admin_url( 'post-new.php?post_type=product&product_type=bopobb' ) ) ?>" |
| 254 | target="_blank"> |
| 255 | <?php echo esc_url( admin_url( 'post-new.php?post_type=product' ) ) ?> |
| 256 | </a> |
| 257 | </h5> |
| 258 | <?php } ?> |
| 259 | <tr valign="top"> |
| 260 | <th scope="row"> |
| 261 | <h4 class="vi-ui blue header"><?php esc_html_e( 'Bundle', 'woo-bopo-bundle' ); ?></h4> |
| 262 | </th> |
| 263 | </tr> |
| 264 | <tr valign="top"> |
| 265 | <th scope="row"> |
| 266 | <label for="bopobb_item_view"> |
| 267 | <?php esc_html_e( 'Item view', 'woo-bopo-bundle' ) ?> |
| 268 | </label> |
| 269 | </th> |
| 270 | <td> |
| 271 | <div class="vi-ui toggle checkbox"> |
| 272 | <input type="checkbox" tabindex="0" |
| 273 | id="bopobb_view_quantity" <?php checked( $this->settings->get_params( 'bopobb_view_quantity' ), 1 ) ?> |
| 274 | name="bopobb_view_quantity" value="1"> |
| 275 | <label><?php esc_html_e( 'Show quantity', 'woo-bopo-bundle' ); ?></label> |
| 276 | </div> |
| 277 | </td> |
| 278 | </tr> |
| 279 | <tr valign="top"> |
| 280 | <th scope="row"> |
| 281 | <label for="bopobb_view_stock"> |
| 282 | </label> |
| 283 | </th> |
| 284 | <td> |
| 285 | <div class="vi-ui toggle checkbox"> |
| 286 | <input type="checkbox" |
| 287 | id="bopobb_view_stock" <?php checked( $this->settings->get_params( 'bopobb_view_stock' ), 1 ) ?> |
| 288 | name="bopobb_view_stock" value="1"> |
| 289 | <label><?php esc_html_e( 'Show stock', 'woo-bopo-bundle' ); ?></label> |
| 290 | </div> |
| 291 | </td> |
| 292 | </tr> |
| 293 | <tr valign="top"> |
| 294 | <th scope="row"> |
| 295 | <label for="bopobb_view_ratting"> |
| 296 | </label> |
| 297 | </th> |
| 298 | <td> |
| 299 | <div class="vi-ui toggle checkbox"> |
| 300 | <input type="checkbox" |
| 301 | id="bopobb_view_ratting" <?php checked( $this->settings->get_params( 'bopobb_view_ratting' ), 1 ) ?> |
| 302 | name="bopobb_view_ratting" value="1"> |
| 303 | <label><?php esc_html_e( 'Show rating', 'woo-bopo-bundle' ); ?></label> |
| 304 | </div> |
| 305 | </td> |
| 306 | </tr> |
| 307 | <tr valign="top"> |
| 308 | <th scope="row"> |
| 309 | <label for="bopobb_view_description"> |
| 310 | </label> |
| 311 | </th> |
| 312 | <td> |
| 313 | <div class="vi-ui toggle checkbox"> |
| 314 | <input type="checkbox" |
| 315 | id="bopobb_view_description" <?php checked( $this->settings->get_params( 'bopobb_view_description' ), 1 ) ?> |
| 316 | name="bopobb_view_description" value="1"> |
| 317 | <label><?php esc_html_e( 'Show short description(on hover)', 'woo-bopo-bundle' ); ?></label> |
| 318 | </div> |
| 319 | </td> |
| 320 | </tr> |
| 321 | <tr valign="top"> |
| 322 | <th scope="row"> |
| 323 | <label for="bopobb_link_individual"> |
| 324 | <?php esc_html_e( 'Link to individual product', 'woo-bopo-bundle' ) ?></label> |
| 325 | </th> |
| 326 | <td> |
| 327 | <select class="vi-ui fluid dropdown" id="bopobb_link_individual" tabindex="1" |
| 328 | name="bopobb_link_individual"> |
| 329 | <option <?php selected( $this->settings->get_params( 'bopobb_link_individual' ), 0 ) ?> |
| 330 | value="0"><?php esc_html_e( 'No link', 'woo-bopo-bundle' ) ?></option> |
| 331 | <option <?php selected( $this->settings->get_params( 'bopobb_link_individual' ), 1 ) ?> |
| 332 | value="1"><?php esc_html_e( 'New tab', 'woo-bopo-bundle' ) ?></option> |
| 333 | <option <?php selected( $this->settings->get_params( 'bopobb_link_individual' ), 2 ) ?> |
| 334 | value="2"><?php esc_html_e( 'A bundle product changing popup', 'woo-bopo-bundle' ) ?></option> |
| 335 | </select> |
| 336 | <p class="description"><?php esc_html_e( 'Action after clicking on product title of bundle', 'woo-bopo-bundle' ); ?></p> |
| 337 | </td> |
| 338 | </tr> |
| 339 | <tr valign="top"> |
| 340 | <th scope="row"> |
| 341 | <label for="bopobb_single_template"> |
| 342 | <?php esc_html_e( 'Template', 'woo-bopo-bundle' ) ?></label> |
| 343 | </th> |
| 344 | <td> |
| 345 | <select class="vi-ui fluid dropdown" id="bopobb_single_template" tabindex="1" |
| 346 | name="bopobb_single_template"> |
| 347 | <option <?php selected( $this->settings->get_params( 'bopobb_single_template' ), 1 ) ?> |
| 348 | value="1"><?php esc_html_e( 'Vertical bundle template', 'woo-bopo-bundle' ) ?></option> |
| 349 | <option <?php selected( $this->settings->get_params( 'bopobb_single_template' ), 2 ) ?> |
| 350 | value="2"><?php esc_html_e( 'Horizontal bundle template', 'woo-bopo-bundle' ) ?></option> |
| 351 | </select> |
| 352 | <p class="description"></p> |
| 353 | </td> |
| 354 | </tr> |
| 355 | <!-- <tr valign="top">--> |
| 356 | <!-- <th scope="row">--> |
| 357 | <!-- <h4 class="vi-ui blue header">--><?php //esc_html_e( 'Change product button', 'woo-bopo-bundle' ); ?><!--</h4>--> |
| 358 | <!-- </th>--> |
| 359 | <!-- </tr>--> |
| 360 | <!-- <tr valign="top">--> |
| 361 | <!-- <th scope="row">--> |
| 362 | <!-- <label for="bopobb_swap_text">--> |
| 363 | <!-- --><?php //esc_html_e( 'Text', 'woo-bopo-bundle' ) ?><!--</label>--> |
| 364 | <!-- </th>--> |
| 365 | <!-- <td>--> |
| 366 | <!-- <input type="text" id="bopobb_swap_text" tabindex="2" name="bopobb_swap_text"--> |
| 367 | <!-- value="--><?php //echo esc_attr( $this->settings->get_params( 'bopobb_swap_text' ) ); ?><!--"--> |
| 368 | <!-- placeholder="--><?php //esc_html_e( 'Change', 'woo-bopo-bundle' ) ?><!--">--> |
| 369 | <!-- </td>--> |
| 370 | <!-- </tr>--> |
| 371 | <!-- <tr valign="top">--> |
| 372 | <!-- <th scope="row">--> |
| 373 | <!-- <label for="bopobb_swap_color">--> |
| 374 | <!-- --><?php //esc_html_e( 'Color', 'woo-bopo-bundle' ) ?><!--</label>--> |
| 375 | <!-- </th>--> |
| 376 | <!-- <td>--> |
| 377 | <!-- <input name="bopobb_swap_color" id="bopobb_swap_color" tabindex="3" type="text"--> |
| 378 | <!-- class="color-picker"--> |
| 379 | <!-- value="--><?php //if ( $this->settings->get_params( 'bopobb_swap_color' ) ) { |
| 380 | // echo esc_attr( $this->settings->get_params( 'bopobb_swap_color' ) ); |
| 381 | // } ?><!--"--> |
| 382 | <!-- style="background: --><?php //if ( $this->settings->get_params( 'bopobb_swap_color' ) ) { |
| 383 | // echo esc_attr( $this->settings->get_params( 'bopobb_swap_color' ) ); |
| 384 | // } ?> |
| 385 | <!-- </td>--> |
| 386 | <!-- </tr>--> |
| 387 | <!-- <tr valign="top">--> |
| 388 | <!-- <th scope="row">--> |
| 389 | <!-- <label for="bopobb_swap_background">--> |
| 390 | <?php //esc_html_e( 'Background color', 'woo-bopo-bundle' ) ?><!--</label>--> |
| 391 | <!-- </th>--> |
| 392 | <!-- <td>--> |
| 393 | <!-- <input name="bopobb_swap_background" id="bopobb_swap_background" tabindex="4"--> |
| 394 | <!-- type="text" class="color-picker"--> |
| 395 | <!-- value="--><?php //if ( $this->settings->get_params( 'bopobb_swap_background' ) ) { |
| 396 | // echo esc_attr( $this->settings->get_params( 'bopobb_swap_background' ) ); |
| 397 | // } ?><!--"--> |
| 398 | <!-- style="background: --><?php //if ( $this->settings->get_params( 'bopobb_swap_background' ) ) { |
| 399 | // echo esc_attr( $this->settings->get_params( 'bopobb_swap_background' ) ); |
| 400 | // } ?> |
| 401 | <!-- </td>--> |
| 402 | <!-- </tr>--> |
| 403 | <tr valign="top"> |
| 404 | <th scope="row"> |
| 405 | <h4 class="vi-ui blue header"><?php esc_html_e( 'Popup change product', 'woo-bopo-bundle' ); ?></h4> |
| 406 | </th> |
| 407 | </tr> |
| 408 | <tr valign="top"> |
| 409 | <th scope="row"> |
| 410 | <label for="bopobb_popup_title"> |
| 411 | <?php esc_html_e( 'Title', 'woo-bopo-bundle' ) ?></label> |
| 412 | </th> |
| 413 | <td> |
| 414 | <input type="text" id="bopobb_popup_title" tabindex="2" name="bopobb_popup_title" |
| 415 | value="<?php echo esc_attr( $this->settings->get_params( 'bopobb_popup_title' ) ); ?>" |
| 416 | placeholder="<?php esc_html_e( 'Select product to bundle', 'woo-bopo-bundle' ) ?>"> |
| 417 | <?php |
| 418 | if ( $this->languages_count ) { |
| 419 | foreach ( $this->languages as $key => $value ) { |
| 420 | ?> |
| 421 | <p> |
| 422 | <label for="<?php echo esc_attr( 'bopobb_popup_title_' . $value ); ?>"><?php |
| 423 | if ( isset( $this->languages_data[ $value ]['country_flag_url'] ) && $this->languages_data[ $value ]['country_flag_url'] ) { |
| 424 | ?> |
| 425 | <img src="<?php echo esc_url( $this->languages_data[ $value ]['country_flag_url'] ); ?>"> |
| 426 | <?php |
| 427 | } |
| 428 | echo esc_html( $value ); |
| 429 | if ( isset( $this->languages_data[ $value ]['translated_name'] ) ) { |
| 430 | echo esc_html( '(' . $this->languages_data[ $value ]['translated_name'] . ')' ); |
| 431 | } |
| 432 | ?>:</label> |
| 433 | </p> |
| 434 | <input type="text" |
| 435 | id="<?php echo esc_attr( 'bopobb_popup_title_' . $value ) ?>" |
| 436 | tabindex="7" |
| 437 | name="<?php echo esc_attr( 'bopobb_popup_title_' . $value ) ?>" |
| 438 | value="<?php echo esc_attr( $this->settings->get_params( 'bopobb_popup_title_' . $value ) ); ?>" |
| 439 | placeholder="<?php esc_attr_e( 'Please select your product', 'woocommerce-bopo-bundle' ) ?>"> |
| 440 | <?php |
| 441 | } |
| 442 | } |
| 443 | ?> |
| 444 | </td> |
| 445 | </tr> |
| 446 | <tr valign="top"> |
| 447 | <th scope="row"> |
| 448 | <label for="bopobb_popup_color"> |
| 449 | <?php esc_html_e( 'Color', 'woo-bopo-bundle' ) ?></label> |
| 450 | </th> |
| 451 | <td> |
| 452 | <input name="bopobb_popup_color" id="bopobb_popup_color" tabindex="5" type="text" |
| 453 | class="color-picker" |
| 454 | value="<?php if ( $this->settings->get_params( 'bopobb_popup_color' ) ) { |
| 455 | echo esc_attr( $this->settings->get_params( 'bopobb_popup_color' ) ); |
| 456 | } ?>" |
| 457 | style="background: <?php if ( $this->settings->get_params( 'bopobb_popup_color' ) ) { |
| 458 | echo esc_attr( $this->settings->get_params( 'bopobb_popup_color' ) ); |
| 459 | } ?>;"/> |
| 460 | </td> |
| 461 | </tr> |
| 462 | <tr valign="top"> |
| 463 | <th scope="row"> |
| 464 | <label for="bopobb_popup_background"> |
| 465 | <?php esc_html_e( 'Background color', 'woo-bopo-bundle' ) ?></label> |
| 466 | </th> |
| 467 | <td> |
| 468 | <input name="bopobb_popup_background" id="bopobb_popup_background" tabindex="4" |
| 469 | type="text" class="color-picker" |
| 470 | value="<?php if ( $this->settings->get_params( 'bopobb_popup_background' ) ) { |
| 471 | echo esc_attr( $this->settings->get_params( 'bopobb_popup_background' ) ); |
| 472 | } ?>" |
| 473 | style="background: <?php if ( $this->settings->get_params( 'bopobb_popup_background' ) ) { |
| 474 | echo esc_attr( $this->settings->get_params( 'bopobb_popup_background' ) ); |
| 475 | } ?>;"/> |
| 476 | </td> |
| 477 | </tr> |
| 478 | <tr valign="top"> |
| 479 | <th scope="row"> |
| 480 | <label for="bopobb_popup_page_items"> |
| 481 | |
| 482 | <?php esc_html_e( 'Number product per page', 'woocommerce-bopo-bundle' ) ?></label> |
| 483 | </th> |
| 484 | <td> |
| 485 | <input type="number" name="bopobb_popup_page_items" id="bopobb_popup_page_items" |
| 486 | tabindex="13" type="text" class="bopobb-popup-column" |
| 487 | step="1" min="1" max="100" |
| 488 | value="<?php if ( $this->settings->get_params( 'bopobb_popup_page_items' ) ) { |
| 489 | echo esc_attr( $this->settings->get_params( 'bopobb_popup_page_items' ) ); |
| 490 | } ?>"/> |
| 491 | </td> |
| 492 | </tr> |
| 493 | |
| 494 | </tbody> |
| 495 | </table> |
| 496 | </div> |
| 497 | <p> |
| 498 | <input type="submit" name="bopobb_save_data" |
| 499 | value="<?php esc_html_e( 'Save', 'woo-bopo-bundle' ); ?>" class="vi-ui primary button"> |
| 500 | </p> |
| 501 | </form> |
| 502 | </div> |
| 503 | </div> |
| 504 | <?php |
| 505 | do_action( 'villatheme_support_bopo-woo-product-bundle-builder' ); |
| 506 | } |
| 507 | |
| 508 | /** |
| 509 | * Link to Settings |
| 510 | * |
| 511 | * @param $links |
| 512 | * |
| 513 | * @return mixed |
| 514 | */ |
| 515 | public function settings_link( $links ) { |
| 516 | $settings_link = '<a href="admin.php?page=woo-bopo-bundle" title="' . __( 'Bopo - Woo Product Bundle Builder', 'woo-bopo-bundle' ) . '">' . __( 'Settings', 'woo-bopo-bundle' ) . '</a>'; |
| 517 | array_unshift( $links, $settings_link ); |
| 518 | |
| 519 | return $links; |
| 520 | } |
| 521 | |
| 522 | /** |
| 523 | * Include style and script |
| 524 | */ |
| 525 | public function admin_enqueue_script() { |
| 526 | $page_id = get_current_screen()->id; |
| 527 | if ( $page_id == 'woo-bopo-bundle' || $page_id == 'toplevel_page_woo-bopo-bundle' ) { |
| 528 | // style |
| 529 | wp_enqueue_style( 'woo-bopo-bundle-semantic-button-css', VI_WOO_BOPO_BUNDLE_CSS . 'button.min.css', array(), VI_WOO_BOPO_BUNDLE_VERSION ); |
| 530 | wp_enqueue_style( 'woo-bopo-bundle-semantic-table-css', VI_WOO_BOPO_BUNDLE_CSS . 'table.min.css', array(), VI_WOO_BOPO_BUNDLE_VERSION ); |
| 531 | wp_enqueue_style( 'woo-bopo-bundle-semantic-form-css', VI_WOO_BOPO_BUNDLE_CSS . 'form.min.css', array(), VI_WOO_BOPO_BUNDLE_VERSION ); |
| 532 | wp_enqueue_style( 'woo-bopo-bundle-semantic-dropdown-css', VI_WOO_BOPO_BUNDLE_CSS . 'dropdown.min.css', array(), VI_WOO_BOPO_BUNDLE_VERSION ); |
| 533 | wp_enqueue_style( 'woo-bopo-bundle-semantic-transition-css', VI_WOO_BOPO_BUNDLE_CSS . 'transition.min.css', array(), VI_WOO_BOPO_BUNDLE_VERSION ); |
| 534 | wp_enqueue_style( 'woo-bopo-bundle-semantic-checkbox-css', VI_WOO_BOPO_BUNDLE_CSS . 'checkbox.min.css', array(), VI_WOO_BOPO_BUNDLE_VERSION ); |
| 535 | wp_enqueue_style( 'woo-bopo-bundle-semantic-menu-css', VI_WOO_BOPO_BUNDLE_CSS . 'menu.min.css', array(), VI_WOO_BOPO_BUNDLE_VERSION ); |
| 536 | wp_enqueue_style( 'woo-bopo-bundle-semantic-header-css', VI_WOO_BOPO_BUNDLE_CSS . 'header.min.css', array(), VI_WOO_BOPO_BUNDLE_VERSION ); |
| 537 | wp_enqueue_style( 'woo-bopo-bundle-semantic-segment-css', VI_WOO_BOPO_BUNDLE_CSS . 'segment.min.css', array(), VI_WOO_BOPO_BUNDLE_VERSION ); |
| 538 | wp_enqueue_style( 'woo-bopo-bundle-semantic-icon-css', VI_WOO_BOPO_BUNDLE_CSS . 'icon.min.css', array(), VI_WOO_BOPO_BUNDLE_VERSION ); |
| 539 | |
| 540 | //script |
| 541 | wp_enqueue_script( |
| 542 | 'iris', admin_url( 'js/iris.min.js' ), array( |
| 543 | 'jquery-ui-draggable', |
| 544 | 'jquery-ui-slider', |
| 545 | 'jquery-touch-punch' |
| 546 | ), VI_WOO_BOPO_BUNDLE_VERSION, 1 |
| 547 | ); |
| 548 | if ( WP_DEBUG ) { |
| 549 | wp_enqueue_script( 'woo-bopo-bundle-setting', VI_WOO_BOPO_BUNDLE_JS . 'bopo-settings.js', array( 'jquery' ), VI_WOO_BOPO_BUNDLE_VERSION, false ); |
| 550 | } else { |
| 551 | wp_enqueue_script( 'woo-bopo-bundle-setting', VI_WOO_BOPO_BUNDLE_JS . 'bopo-settings.min.js', array( 'jquery' ), VI_WOO_BOPO_BUNDLE_VERSION, false ); |
| 552 | } |
| 553 | wp_enqueue_script( 'woo-bopo-bundle-semantic-dropdown-js', VI_WOO_BOPO_BUNDLE_JS . 'dropdown.min.js', array( 'jquery' ), VI_WOO_BOPO_BUNDLE_VERSION, false ); |
| 554 | wp_enqueue_script( 'woo-bopo-bundle-semantic-transition-js', VI_WOO_BOPO_BUNDLE_JS . 'transition.min.js', array( 'jquery' ), VI_WOO_BOPO_BUNDLE_VERSION, false ); |
| 555 | } |
| 556 | } |
| 557 | } |