*/ class Cf7_Customizer_Admin { /** * The ID of this plugin. * * @since 1.0.0 * @access private * @var string $plugin_name The ID of this plugin. */ private $plugin_name; /** * The version of this plugin. * * @since 1.0.0 * @access private * @var string $version The current version of this plugin. */ private $version; /** * Initialize the class and set its properties. * * @since 1.0.0 * @param string $plugin_name The name of this plugin. * @param string $version The version of this plugin. */ public function __construct( $plugin_name, $version ) { $this->plugin_name = $plugin_name; $this->version = $version; } /** * Register the stylesheets for the admin area. * * @since 1.0.0 */ public function enqueue_styles() { if(isset($_GET['page']) && sanitize_text_field($_GET['page']) == 'cf7cstmzr_page') { wp_enqueue_style( 'wp-color-picker' ); wp_enqueue_style( 'codemirror', plugin_dir_url( __FILE__ ) . 'vendors/codemirror.css', array(), $this->version . time(), 'all' ); wp_enqueue_style( $this->plugin_name, plugin_dir_url( __FILE__ ) . 'css/cf7-customizer-admin.css', array(), $this->version . time(), 'all' ); } wp_enqueue_style( $this->plugin_name . '-global', plugin_dir_url( __FILE__ ) . 'css/cf7-customizer-admin-global.css', array(), $this->version . time(), 'all' ); } /** * Register the JavaScript for the admin area. * * @since 1.0.0 */ public function enqueue_scripts() { if(isset($_GET['page']) && (sanitize_text_field($_GET['page']) == 'cf7cstmzr_page' || sanitize_text_field($_GET['page']) == 'cf7cstmzr_tutorial_page')) { wp_enqueue_code_editor(array('type' => 'text/css')); if ( ! did_action( 'wp_enqueue_media' ) ) { wp_enqueue_media(); } $enable_for_form_nonce = wp_create_nonce('cf7cstmzr_enable_for_form_nonce'); $disable_for_form_nonce = wp_create_nonce('cf7cstmzr_disable_for_form_nonce'); $save_form_customizer_settings_nonce = wp_create_nonce('cf7cstmzr_save_form_customizer_settings_nonce'); $disable_globally_nonce = wp_create_nonce('cf7cstmzr_disable_globally_nonce'); $enable_globally_nonce = wp_create_nonce('cf7cstmzr_enable_globally_nonce'); $new_form_customizer_settings_nonce = wp_create_nonce('cf7cstmzr_new_form_customizer_settings_nonce'); $delete_form_customizer_settings_nonce = wp_create_nonce('cf7cstmzr_delete_form_customizer_settings_nonce'); $load_body_tag_nonce_nonce = wp_create_nonce('cf7cstmzr_load_body_tag_nonce_nonce'); wp_enqueue_script( 'codemirror', plugin_dir_url( __FILE__ ) . 'vendors/codemirror.js', array( 'jquery' ), '5.49.2', true ); wp_enqueue_script( 'jRespond', plugin_dir_url( __FILE__ ) . 'js/jRespond.js', array( 'jquery' ), '0.10', true ); wp_enqueue_script( $this->plugin_name, plugin_dir_url( __FILE__ ) . 'js/cf7-customizer-admin.js', array( 'jquery', 'jquery-ui-core', 'wp-color-picker' ), $this->version . time(), true ); // Localize the script with your nonce and the AJAX URL wp_localize_script($this->plugin_name, 'cf7cstmzr_ajax_object', array( 'enable_for_form_nonce' => $enable_for_form_nonce, 'disable_for_form_nonce' => $disable_for_form_nonce, 'save_form_customizer_settings_nonce' => $save_form_customizer_settings_nonce, 'disable_globally_nonce' => $disable_globally_nonce, 'enable_globally_nonce' => $enable_globally_nonce, 'new_form_customizer_settings_nonce' => $new_form_customizer_settings_nonce, 'delete_form_customizer_settings_nonce' => $delete_form_customizer_settings_nonce, 'load_body_tag_nonce' => $load_body_tag_nonce_nonce, )); } } public function settings_page() { $is_welcome_done = get_option('cf7cstmzr_welcome_done'); if (!cf7cstmzr_is_plugin_activated( 'contact-form-7', 'wp-contact-form-7.php' )) { add_menu_page( __( 'CF7 Styler', 'cf7-styler' ), __( 'CF7 Styler', 'cf7-styler' ), 'administrator', 'cf7cstmzr_page', array($this, 'render_settings_page'), 'dashicons-email-alt', 6 ); if (!empty($is_welcome_done)) { add_submenu_page( 'cf7cstmzr_page', __( 'Support & KB', 'cf7-styler' ), __( 'Support & KB', 'cf7-styler' ), 'administrator', 'cf7cstmzrcf7cstmzr_tutorial_page', array($this, 'render_tutorials_page') ); } } else { add_submenu_page( 'wpcf7', __( 'CF7 Styler', 'cf7-styler' ), __( 'CF7 Styler', 'cf7-styler' ), 'administrator', 'cf7cstmzr_page', array($this, 'render_settings_page') ); if (!empty($is_welcome_done)) { add_submenu_page( 'wpcf7', __( 'Support & KB', 'cf7-styler' ), ''.__( 'Support & KB', 'cf7-styler' ).'', 'administrator', 'cf7cstmzr_tutorial_page', array($this, 'render_settings_page') ); } } } public function render_settings_page() { $is_welcome_done = get_option('cf7cstmzr_welcome_done'); if (!empty($_GET['page']) && ('cf7cstmzr_tutorial_page' === sanitize_text_field($_GET['page']) || empty($is_welcome_done))) { include_once CF7CSTMZR_PLUGIN_PATH . 'admin/partials/cf7-customizer-admin-tutorial.php'; } else { include_once CF7CSTMZR_PLUGIN_PATH . 'admin/partials/cf7-customizer-admin-display.php'; } } public function check_installation() { $style_schemes = get_option('cf7cstmzr_style_schemes', array()); if (empty($style_schemes)) { $default_scheme = array( 'default' => Cf7_Style_Scheme::get_default_style_scheme() ); update_option('cf7cstmzr_style_schemes', $default_scheme); } } public function rewrite_rule() { flush_rewrite_rules(); add_rewrite_rule('^cf7cstmzr-form-customizer/(.*)/?', 'index.php?cf7cstmzr-form=$matches[1]', 'top'); add_rewrite_tag( '%cf7cstmzr-form%', '([^&]+)' ); } public function check_version() { $plugin_version = Cf7_License::get_license_version(); if ('free' === $plugin_version) { delete_option('cf7cstmzr_enabled_globally'); $individually_styled_forms = Cf7_Style_Scheme::get_individually_styled_forms(); } } public function template_redirect() { $permalink_structure = get_option('permalink_structure'); if (!empty($permalink_structure)) { $form_id = get_query_var( 'cf7cstmzr-form' ); } else { if (!empty($_GET['cf7cstmzr_page']) && !empty($_GET['form_id'])) { $form_id = $_GET['form_id']; } } if ($form_id) { $form_post = get_post($form_id); if (!$form_post || 'publish' !== $form_post->post_status) { die; } global $content_width; if (empty($content_width)) { $content_width = 640; } $content_width = $content_width . 'px'; $content_width = '90%'; $form = get_post($form_id); get_header(); if (!empty($form)) { $preview_mode = get_option('cf7cstmzr-preview-mode', false); $is_split_mode = $preview_mode === 'split-mode'; ?>
post_title . '"]'); ?>
post_title . '"]'); ?>
post_title . '"]'); } ?>
__('CF7 Styler', 'cf7-styler'), 'callback' => array($this, 'show_metabox') ); return $panels; } public function show_metabox($contact_form) { $plugin_version = Cf7_License::get_license_version(); $style_schemes = get_option('cf7cstmzr_style_schemes', array()); $form_id = $contact_form->id(); $selected_style = get_post_meta($form_id, 'cf7cstmzr_style_scheme', true); $individually_styled_forms = Cf7_Style_Scheme::get_individually_styled_forms(); if ('free' === $plugin_version && !empty($individually_styled_forms)) { foreach ($individually_styled_forms as $styled_form_id => $styled_form_style) { $styled_form = get_post($styled_form_id); if (!empty($styled_form)) { $styled_form_title = $styled_form->post_title; $styled_form_style_title = $style_schemes[$styled_form_style]['title']; } } } if (!empty($style_schemes)) { ?>

%s form is styled with %s. As in free version you can style only one form at a time and if you activate style for current form, style will be removed from other form.', 'cf7-styler' ), $styled_form_title, $styled_form_style_title ); ?>

postmeta} WHERE meta_key='cf7cstmzr_style_scheme';"; $wpdb->query($sql); } update_post_meta( $post_ID, 'cf7cstmzr_style_scheme', $cf7cstmzr_style_scheme ); } else { delete_post_meta($post_ID, 'cf7cstmzr_style_scheme'); } } public function plugin_menu_optin() { global $submenu; if (function_exists('cf7_styler')) { $reconnect_url = cf7_styler()->get_activation_url( array( 'nonce' => wp_create_nonce( cf7_styler()->get_unique_affix() . '_reconnect' ), 'fs_action' => ( cf7_styler()->get_unique_affix() . '_reconnect' ), ) ); $is_registered = cf7_styler()->is_registered(); if (!$is_registered && isset($submenu["wpcf7"])) { $submenu["wpcf7"][] = array( '' . __('Opt-in to see account', 'cf7-styler') . '', 'manage_options', $reconnect_url ); } } } }