get_upgrade_notice( '3.0.9' ); echo apply_filters( 'kadence_blocks_in_plugin_update_message', $upgrade_notice ? wp_kses_post( $upgrade_notice ) . '
'; break; } } } return wp_kses_post( $upgrade_notice ); } /** * Filter the exit_interview notice args. * * @param array $default_args the exit_interview args. */ public function exit_interview_args( $default_args ) { $args = [ 'plugin_logo' => KADENCE_BLOCKS_URL . 'includes/settings/img/kadence-logo.png', 'plugin_logo_width' => 50, 'plugin_logo_height' => 50, 'plugin_logo_alt' => 'KadenceWP Logo', 'uninstall_reasons' => [ [ 'uninstall_reason_id' => 'confusing', 'uninstall_reason' => __( 'I couldn\'t understand how to make it work.', 'kadence-blocks' ), 'show_comment' => false, ], [ 'uninstall_reason_id' => 'better-plugin', 'uninstall_reason' => __( 'I found a better plugin.', 'kadence-blocks' ), 'show_comment' => false, ], [ 'uninstall_reason_id' => 'no-feature', 'uninstall_reason' => __( 'I need a specific feature kadence blocks doesn\'t provide.', 'kadence-blocks' ), 'show_comment' => true, ], [ 'uninstall_reason_id' => 'broken', 'uninstall_reason' => __( 'Something is broken.', 'kadence-blocks' ), 'show_comment' => false, ], [ 'uninstall_reason_id' => 'other', 'uninstall_reason' => __( 'Other', 'kadence-blocks' ), 'show_comment' => true, ], ], ]; $args = wp_parse_args( $args, $default_args ); return $args; } /** * Filter the optin notice args. * * @param array $default_args the optin args. */ public function optin_notice_args( $default_args ) { $args = [ 'plugin_logo' => KADENCE_BLOCKS_URL . 'includes/settings/img/kadence-logo.png', 'plugin_logo_width' => 50, 'plugin_logo_height' => 50, 'plugin_logo_alt' => 'KadenceWP Logo', 'plugin_name' => 'Kadence Blocks', 'plugin_slug' => 'kadence-blocks', 'permissions_url' => 'https://www.kadencewp.com/in-app-telemetry/', 'tos_url' => 'https://www.kadencewp.com/terms-and-conditions/', 'privacy_url' => 'https://www.kadencewp.com/privacy-policy/', 'heading' => __( 'Help us make Kadence Blocks even better.', 'kadence-blocks' ), 'intro' => sprintf( // translators: placeholder: username. esc_html__( 'Hi, %1$s! At KadenceWP, we\'re always looking for more ways to make our products better for you. If you opt into sharing some data on your usage of Kadence Blocks, it helps us identify key areas where we can improve. In return, we\'ll also email helpful articles and guides to get more out of Kadence, WordPress, and more. If you skip this, that\'s okay. Kadence Blocks will work just fine. We hope you love building with Kadence.', 'kadence-blocks' ), $default_args['user_name'] ), ]; $args = wp_parse_args( $args, $default_args ); return $args; } /** * Add inline css editor width */ public function admin_editor_width() { if ( apply_filters( 'kadence_blocks_editor_width', $this->show_editor_width() ) ) { $editor_widths = get_option( 'kt_blocks_editor_width', [] ); if ( ( ! isset( $editor_widths['enable_editor_width'] ) || 'true' === $editor_widths['enable_editor_width'] ) && apply_filters( 'kadence_blocks_editor_width', true ) ) { if ( isset( $editor_widths['limited_margins'] ) && 'true' === $editor_widths['limited_margins'] ) { $add_size = 10; } else { $add_size = 30; } $post_type = get_post_type(); if ( isset( $editor_widths['page_default'] ) && ! empty( $editor_widths['page_default'] ) && isset( $editor_widths['post_default'] ) && ! empty( $editor_widths['post_default'] ) ) { if ( isset( $post_type ) && 'page' === $post_type ) { $defualt_size_type = $editor_widths['page_default']; } else { $defualt_size_type = $editor_widths['post_default']; } } else { $defualt_size_type = 'sidebar'; } if ( isset( $editor_widths['sidebar'] ) && ! empty( $editor_widths['sidebar'] ) ) { $sidebar_size = $editor_widths['sidebar'] + $add_size; } else { $sidebar_size = 750; } if ( isset( $editor_widths['nosidebar'] ) && ! empty( $editor_widths['nosidebar'] ) ) { $nosidebar_size = $editor_widths['nosidebar'] + $add_size; } else { $nosidebar_size = 1140 + $add_size; } if ( 'sidebar' == $defualt_size_type ) { $default_size = $sidebar_size; } elseif ( 'fullwidth' == $defualt_size_type ) { $default_size = 'none'; } else { $default_size = $nosidebar_size; } if ( 'none' === $default_size ) { $jssize = 2000; } else { $jssize = $default_size; } echo ''; echo ''; } } } /** * Register Meta for blocks width */ public function init_post_meta() { if ( apply_filters( 'kadence_blocks_editor_width', $this->show_editor_width() ) ) { register_post_meta( '', 'kt_blocks_editor_width', [ 'show_in_rest' => true, 'single' => true, 'type' => 'string', ] ); } } /** * Load Gutenberg Palette in editor. * * @param array $settings The settings. */ public function load_color_palette_editor_settings( $settings ) { $palette = json_decode( get_option( 'kadence_blocks_colors' ), true ); if ( isset( $palette['palette'] ) && is_array( $palette['palette'] ) ) { $san_palette = []; foreach ( $palette['palette'] as $item ) { $san_palette[] = [ 'color' => $item['color'], 'name' => $item['name'], 'slug' => $item['slug'], ]; } if ( isset( $san_palette[0] ) ) { if ( ( isset( $palette['override'] ) && true !== $palette['override'] ) || ! isset( $palette['override'] ) ) { $theme_palette = get_theme_support( 'editor-color-palette' ); if ( isset( $settings['colors'] ) && is_array( $settings['colors'] ) ) { $newpalette = array_merge( $settings['colors'], $san_palette ); $newpalette = array_values( array_map( 'unserialize', array_unique( array_map( 'serialize', $newpalette ) ) ) ); } else { $default_palette = [ [ 'name' => __( 'Pale pink', 'kadence-blocks' ), 'slug' => 'pale-pink', 'color' => '#f78da7', ], [ 'name' => __( 'Vivid red', 'kadence-blocks' ), 'slug' => 'vivid-red', 'color' => '#cf2e2e', ], [ 'name' => __( 'Luminous vivid orange', 'kadence-blocks' ), 'slug' => 'luminous-vivid-orange', 'color' => '#ff6900', ], [ 'name' => __( 'Luminous vivid amber', 'kadence-blocks' ), 'slug' => 'luminous-vivid-amber', 'color' => '#fcb900', ], [ 'name' => __( 'Light green cyan', 'kadence-blocks' ), 'slug' => 'light-green-cyan', 'color' => '#7bdcb5', ], [ 'name' => __( 'Vivid green cyan', 'kadence-blocks' ), 'slug' => 'vivid-green-cyan', 'color' => '#00d084', ], [ 'name' => __( 'Pale cyan blue', 'kadence-blocks' ), 'slug' => 'pale-cyan-blue', 'color' => '#8ed1fc', ], [ 'name' => __( 'Vivid cyan blue', 'kadence-blocks' ), 'slug' => 'vivid-cyan-blue', 'color' => '#0693e3', ], [ 'name' => __( 'Very light gray', 'kadence-blocks' ), 'slug' => 'very-light-gray', 'color' => '#eeeeee', ], [ 'name' => __( 'Cyan bluish gray', 'kadence-blocks' ), 'slug' => 'cyan-bluish-gray', 'color' => '#abb8c3', ], [ 'name' => __( 'Very dark gray', 'kadence-blocks' ), 'slug' => 'very-dark-gray', 'color' => '#313131', ], ]; $newpalette = array_values( array_merge( $default_palette, $san_palette ) ); } } else { $newpalette = array_values( $san_palette ); } $settings['colors'] = $newpalette; if ( function_exists( 'get_block_editor_settings' ) ) { if ( isset( $settings['__experimentalFeatures']['color']['palette']['theme'] ) && is_array( $settings['__experimentalFeatures']['color']['palette']['theme'] ) ) { $newpalette = array_merge( $settings['__experimentalFeatures']['color']['palette']['theme'], $san_palette ); $newpalette = array_values( array_map( 'unserialize', array_unique( array_map( 'serialize', $newpalette ) ) ) ); } $settings['__experimentalFeatures']['color']['palette']['theme'] = $newpalette; } } } return $settings; } /** * Load Gutenberg Palette */ public function load_color_palette() { $palette = json_decode( get_option( 'kadence_blocks_colors' ) ); if ( $palette && is_object( $palette ) && isset( $palette->palette ) && is_array( $palette->palette ) ) { $san_palette = []; foreach ( $palette->palette as $item ) { $san_palette[] = [ 'color' => $item->color, 'name' => $item->name, 'slug' => $item->slug, ]; } if ( isset( $san_palette[0] ) ) { if ( ( isset( $palette->override ) && true !== $palette->override ) || ! isset( $palette->override ) ) { $theme_palette = get_theme_support( 'editor-color-palette' ); if ( is_array( $theme_palette ) ) { $newpalette = array_merge( reset( $theme_palette ), $san_palette ); } else { $default_palette = [ [ 'name' => __( 'Pale pink', 'kadence-blocks' ), 'slug' => 'pale-pink', 'color' => '#f78da7', ], [ 'name' => __( 'Vivid red', 'kadence-blocks' ), 'slug' => 'vivid-red', 'color' => '#cf2e2e', ], [ 'name' => __( 'Luminous vivid orange', 'kadence-blocks' ), 'slug' => 'luminous-vivid-orange', 'color' => '#ff6900', ], [ 'name' => __( 'Luminous vivid amber', 'kadence-blocks' ), 'slug' => 'luminous-vivid-amber', 'color' => '#fcb900', ], [ 'name' => __( 'Light green cyan', 'kadence-blocks' ), 'slug' => 'light-green-cyan', 'color' => '#7bdcb5', ], [ 'name' => __( 'Vivid green cyan', 'kadence-blocks' ), 'slug' => 'vivid-green-cyan', 'color' => '#00d084', ], [ 'name' => __( 'Pale cyan blue', 'kadence-blocks' ), 'slug' => 'pale-cyan-blue', 'color' => '#8ed1fc', ], [ 'name' => __( 'Vivid cyan blue', 'kadence-blocks' ), 'slug' => 'vivid-cyan-blue', 'color' => '#0693e3', ], [ 'name' => __( 'Very light gray', 'kadence-blocks' ), 'slug' => 'very-light-gray', 'color' => '#eeeeee', ], [ 'name' => __( 'Cyan bluish gray', 'kadence-blocks' ), 'slug' => 'cyan-bluish-gray', 'color' => '#abb8c3', ], [ 'name' => __( 'Very dark gray', 'kadence-blocks' ), 'slug' => 'very-dark-gray', 'color' => '#313131', ], ]; $newpalette = array_merge( $default_palette, $san_palette ); } } else { $newpalette = $san_palette; } add_theme_support( 'editor-color-palette', $newpalette ); add_action( 'wp_head', [ $this, 'print_gutenberg_style' ], 8 ); add_action( 'admin_print_styles', [ $this, 'print_gutenberg_style' ], 21 ); } } } /** * Print Gutenberg Palette Styles */ public function print_gutenberg_style() { if ( is_admin() ) { $screen = get_current_screen(); if ( ! $screen || ! $screen->is_block_editor() ) { return; } } $palette = json_decode( get_option( 'kadence_blocks_colors' ) ); if ( $palette && is_object( $palette ) && isset( $palette->palette ) && is_array( $palette->palette ) ) { $san_palette = []; foreach ( $palette->palette as $item ) { $san_palette[] = [ 'color' => $item->color, 'name' => $item->name, 'slug' => $item->slug, ]; } if ( isset( $san_palette[0] ) ) { echo ''; } } } /** * Redirect to the settings page on activation */ public function activation_redirect() { if ( get_option( 'kadence_blocks_redirect_on_activation', false ) ) { delete_option( 'kadence_blocks_redirect_on_activation' ); // @todo add admin notice for optional data share. } } /** * Redirect to the settings page on activation. * * @param string $key setting key. */ public static function get_data_options( $key ) { if ( ! isset( self::$settings[ $key ] ) ) { self::$settings[ $key ] = get_option( $key, [] ); } return self::$settings[ $key ]; } /** * Deregister Blocks. */ public function deregister_blocks() { // Scripts. $options = get_option( 'kt_blocks_unregistered_blocks' ); if ( isset( $options['kadence/advnacedgallery'] ) ) { unset( $options['kadence/advnacedgallery'] ); update_option( 'kt_blocks_unregistered_blocks', $options ); } // Don't need to unregister a block that is not loaded. if ( ! class_exists( 'woocommerce' ) && is_array( $options ) ) { if ( in_array( 'kadence/productcarousel', $options, true ) ) { foreach ( $options as $key => $block ) { if ( $block === 'kadence/productcarousel' ) { unset( $options[ $key ] ); } } } } if ( $options ) { wp_enqueue_script( 'kadence-blocks-deregister-js', KADENCE_BLOCKS_URL . 'includes/assets/js/admin-blocks-deregister.min.js', [ 'wp-blocks' ], KADENCE_BLOCKS_VERSION, true ); wp_localize_script( 'kadence-blocks-deregister-js', 'kt_deregister_params', [ 'deregister' => $options, ] ); } } /** * Returns a base64 URL for the SVG for use in the menu. * * @param bool $base64 Whether or not to return base64-encoded SVG. * @return string */ private function get_icon_svg( $base64 = true ) { $svg = apply_filters( 'kadence_blocks_admin_svg_icon', '' ); if ( $base64 ) { return 'data:image/svg+xml;base64,' . base64_encode( $svg ); } return $svg; } /** * Allow settings visibility to be changed. */ public function settings_user_capabilities() { return apply_filters( 'kadence_blocks_admin_settings_capability', 'edit_pages' ); } /** * Add option page menu */ public function add_network_menu() { $network_enabled = kadence_blocks_is_network_authorize_enabled(); if ( $network_enabled && function_exists( 'is_plugin_active_for_network' ) && is_plugin_active_for_network( 'kadence-blocks/kadence-blocks.php' ) ) { add_menu_page( __( 'Kadence Blocks - Gutenberg Page Builder Blocks', 'kadence-blocks' ), __( 'Kadence', 'kadence-blocks' ), $this->settings_user_capabilities(), 'kadence-blocks-home', null, $this->get_icon_svg() ); $home_page = add_submenu_page( 'kadence-blocks', __( 'Kadence Blocks', 'kadence-blocks' ), __( 'Home', 'kadence-blocks' ), $this->settings_user_capabilities(), 'kadence-blocks-home', [ $this, 'home_page' ], 0 ); add_action( 'admin_print_styles-' . $home_page, [ $this, 'home_scripts' ] ); } } /** * Add option page menu */ public function add_menu() { add_menu_page( __( 'Kadence Blocks - Gutenberg Page Builder Blocks', 'kadence-blocks' ), __( 'Kadence', 'kadence-blocks' ), $this->settings_user_capabilities(), 'kadence-blocks', null, $this->get_icon_svg() ); $home_page = add_submenu_page( 'kadence-blocks', __( 'Kadence Blocks', 'kadence-blocks' ), __( 'Home', 'kadence-blocks' ), $this->settings_user_capabilities(), 'kadence-blocks-home', [ $this, 'home_page' ], 0 ); $page = add_submenu_page( 'kadence-blocks', __( 'Kadence Blocks - Gutenberg Page Builder Blocks', 'kadence-blocks' ), __( 'Settings', 'kadence-blocks' ), $this->settings_user_capabilities(), 'kadence-blocks', [ $this, 'config_page' ], 1 ); add_action( 'admin_print_styles-' . $home_page, [ $this, 'home_scripts' ] ); add_action( 'admin_print_styles-' . $page, [ $this, 'scripts' ] ); } /** * Loads admin style sheets and scripts */ public function scripts() { $texts = [ 'close' => __( 'Close', 'kadence-blocks' ), 'save' => __( 'Save', 'kadence-blocks' ), 'updating' => __( 'Updating', 'kadence-blocks' ), 'updated' => __( 'Updated', 'kadence-blocks' ), 'config' => __( 'Config', 'kadence-blocks' ), 'settings' => __( 'Default Settings', 'kadence-blocks' ), ]; $settings = [ 'kadence/spacer' => [ 'moved' => [ 'type' => 'info', 'name' => __( 'Setting defaults has moved into Gutenberg, click on the top right corner settings and go to Kadence Blocks Controls', 'kadence-blocks' ), ], ], 'kadence/rowlayout' => [ 'moved' => [ 'type' => 'info', 'name' => __( 'Setting defaults has moved into Gutenberg, click on the top right corner settings and go to Kadence Blocks Controls', 'kadence-blocks' ), ], ], 'kadence/advancedbtn' => [ 'moved' => [ 'type' => 'info', 'name' => __( 'Setting defaults has moved into Gutenberg, click on the top right corner settings and go to Kadence Blocks Controls', 'kadence-blocks' ), ], ], 'kadence/infobox' => [ 'moved' => [ 'type' => 'info', 'name' => __( 'Setting defaults has moved into Gutenberg, click on the top right corner settings and go to Kadence Blocks Controls', 'kadence-blocks' ), ], ], 'kadence/accordion' => [ 'moved' => [ 'type' => 'info', 'name' => __( 'Setting defaults has moved into Gutenberg, click on the top right corner settings and go to Kadence Blocks Controls', 'kadence-blocks' ), ], ], 'kadence/tabs' => [ 'moved' => [ 'type' => 'info', 'name' => __( 'Setting defaults has moved into Gutenberg, click on the top right corner settings and go to Kadence Blocks Controls', 'kadence-blocks' ), ], ], 'kadence/iconlist' => [ 'moved' => [ 'type' => 'info', 'name' => __( 'Setting defaults has moved into Gutenberg, click on the top right corner settings and go to Kadence Blocks Controls', 'kadence-blocks' ), ], ], 'kadence/testimonials' => [ 'moved' => [ 'type' => 'info', 'name' => __( 'Setting defaults has moved into Gutenberg, click on the top right corner settings and go to Kadence Blocks Controls', 'kadence-blocks' ), ], ], 'kadence/advancedheading' => [ 'moved' => [ 'type' => 'info', 'name' => __( 'Setting defaults has moved into Gutenberg, click on the top right corner settings and go to Kadence Blocks Controls', 'kadence-blocks' ), ], ], 'kadence/icon' => [ 'moved' => [ 'type' => 'info', 'name' => __( 'Setting defaults has moved into Gutenberg, click on the top right corner settings and go to Kadence Blocks Controls', 'kadence-blocks' ), ], ], ]; wp_enqueue_style( 'kadence-blocks-admin-css', KADENCE_BLOCKS_URL . 'includes/assets/css/admin-dashboard.min.css', [ 'wp-jquery-ui-dialog', 'wp-color-picker' ], KADENCE_BLOCKS_VERSION, 'all' ); wp_enqueue_script( 'kadence-blocks-admin-js', KADENCE_BLOCKS_URL . 'includes/assets/js/admin-scripts.min.js', [ 'jquery', 'jquery-ui-dialog', 'wp-color-picker' ], KADENCE_BLOCKS_VERSION, true ); wp_localize_script( 'kadence-blocks-admin-js', 'kt_blocks_params', [ 'ajaxurl' => admin_url( 'admin-ajax.php' ), 'wpnonce' => wp_create_nonce( 'kadence-blocks-manage' ), 'blockConfig' => get_option( 'kt_blocks_config_blocks' ), 'blockConfigSettings' => $settings, 'texts' => $texts, ] ); } /** * Loads admin style sheets and scripts */ public function home_scripts() { $using_network_enabled = false; $is_network_admin = is_multisite() && is_network_admin() ? true : false; $network_enabled = kadence_blocks_is_network_authorize_enabled(); if ( $network_enabled && function_exists( 'is_plugin_active_for_network' ) && is_plugin_active_for_network( 'kadence-blocks/kadence-blocks.php' ) ) { $using_network_enabled = true; } $token = get_authorization_token( 'kadence-blocks' ); $auth_url = build_auth_url( apply_filters( 'kadence-blocks-auth-slug', 'kadence-blocks' ), get_license_domain() ); $license_key = kadence_blocks_get_current_license_key(); $disconnect_url = ''; $is_authorized = false; if ( ! empty( $license_key ) && ! kadence_blocks_is_ai_disabled() ) { $is_authorized = is_authorized( $license_key, 'kadence-blocks', ( ! empty( $token ) ? $token : '' ), get_license_domain() ); } if ( $is_authorized ) { $disconnect_url = get_disconnect_url( 'kadence-blocks' ); } // Icons Scripts & Styles. $kadence_icons_meta = kadence_blocks_get_asset_file( 'dist/icons' ); wp_register_script( 'kadence-icons', KADENCE_BLOCKS_URL . 'dist/icons.js', array_merge( $kadence_icons_meta['dependencies'], [ 'wp-api' ] ), $kadence_icons_meta['version'], true ); wp_set_script_translations( 'kadence-icons', 'kadence-blocks' ); $kadence_base = kadence_blocks_get_asset_file( 'dist/extension-kadence-base' ); wp_register_script( 'kadence-blocks-js', KADENCE_BLOCKS_URL . 'dist/extension-kadence-base.js', array_merge( $kadence_base['dependencies'], [ 'wp-api' ] ), $kadence_base['version'], true ); // Block CSS Scripts & Styles. $kadence_stores_meta = kadence_blocks_get_asset_file( 'dist/extension-stores' ); wp_register_script( 'kadence-extension-stores', KADENCE_BLOCKS_URL . 'dist/extension-stores.js', array_merge( $kadence_stores_meta['dependencies'], [ 'wp-api', 'kadence-blocks-js' ] ), $kadence_stores_meta['version'], true ); // wp_register_style( 'kadence-extension-stores', KADENCE_BLOCKS_URL . 'dist/extension/stores.css', array( 'wp-edit-blocks' ), $kadence_stores_meta['version'] ); wp_set_script_translations( 'kadence-extension-stores', 'kadence-blocks' ); // Helpers Scripts & Styles. $kadence_helpers_meta = kadence_blocks_get_asset_file( 'dist/helpers' ); wp_register_script( 'kadence-helpers', KADENCE_BLOCKS_URL . 'dist/helpers.js', array_merge( $kadence_helpers_meta['dependencies'], [ 'wp-api' ] ), $kadence_helpers_meta['version'], true ); wp_set_script_translations( 'kadence-helpers', 'kadence-blocks' ); // Components Scripts & Styles. $kadence_components_meta = kadence_blocks_get_asset_file( 'dist/components' ); wp_register_script( 'kadence-components', KADENCE_BLOCKS_URL . 'dist/components.js', array_merge( $kadence_components_meta['dependencies'], [ 'wp-api', 'kadence-extension-stores', 'kadence-blocks-js' ] ), $kadence_components_meta['version'], true ); wp_register_style( 'kadence-components', KADENCE_BLOCKS_URL . 'dist/components.css', [ 'wp-edit-blocks' ], $kadence_components_meta['version'] ); wp_set_script_translations( 'kadence-components', 'kadence-blocks' ); $kadence_home_meta = kadence_blocks_get_asset_file( 'dist/admin-kadence-home' ); wp_enqueue_script( 'admin-kadence-home', KADENCE_BLOCKS_URL . 'dist/admin-kadence-home.js', $kadence_home_meta['dependencies'], $kadence_home_meta['version'], true ); wp_enqueue_style( 'admin-kadence-home', KADENCE_BLOCKS_URL . 'dist/admin-kadence-home.css', [ 'wp-edit-blocks', 'kadence-components' ], $kadence_home_meta['version'] ); wp_localize_script( 'admin-kadence-home', 'kadenceHomeParams', [ 'ajaxurl' => admin_url( 'admin-ajax.php' ), 'wpnonce' => wp_create_nonce( 'kadence-blocks-manage' ), 'site_name' => sanitize_title( get_bloginfo( 'name' ) ), 'pSlug' => apply_filters( 'kadence-blocks-auth-slug', 'kadence-blocks' ), 'isAIDisabled' => kadence_blocks_is_ai_disabled(), 'pVersion' => KADENCE_BLOCKS_VERSION, 'isAuthorized' => $is_authorized, 'licenseKey' => $license_key, 'authUrl' => esc_url( $auth_url ), 'disconnectUrl' => esc_url( $disconnect_url ), 'pro' => ( class_exists( 'Kadence_Blocks_Pro' ) ? 'true' : 'false' ), 'apiKey' => $license_key, 'isNetworkAdmin' => $is_network_admin, 'isNetworkEnabled' => $using_network_enabled, ] ); wp_set_script_translations( 'admin-kadence-home', 'kadence-blocks' ); wp_enqueue_style( 'kadence-blocks-admin-css', KADENCE_BLOCKS_URL . 'includes/assets/css/admin-dashboard.min.css', [ 'wp-jquery-ui-dialog', 'wp-color-picker' ], KADENCE_BLOCKS_VERSION, 'all' ); wp_enqueue_media(); } /** * Register settings */ public function load_api_settings() { register_setting( 'kadence_blocks_config_blocks', 'kadence_blocks_config_blocks', [ 'type' => 'string', 'description' => __( 'Config Kadence Block Defaults', 'kadence-blocks' ), 'sanitize_callback' => 'sanitize_text_field', 'show_in_rest' => true, 'default' => '', ] ); register_setting( 'kadence_blocks_settings_blocks', 'kadence_blocks_settings_blocks', [ 'type' => 'string', 'description' => __( 'Config Kadence Block visibility settings', 'kadence-blocks' ), 'sanitize_callback' => 'sanitize_text_field', 'show_in_rest' => true, 'default' => '', ] ); register_setting( 'kadence_blocks_settings', 'kadence_blocks_settings', [ 'type' => 'string', 'description' => __( 'Config Kadence Block Settings', 'kadence-blocks' ), 'sanitize_callback' => 'sanitize_text_field', 'show_in_rest' => true, 'default' => '', ] ); register_setting( 'kadence_blocks_prophecy', 'kadence_blocks_prophecy', [ 'type' => 'string', 'description' => __( 'Config Kadence Block Prophecy AI', 'kadence-blocks' ), 'sanitize_callback' => 'sanitize_text_field', 'show_in_rest' => true, 'default' => '', ] ); register_setting( 'kadence_blocks_colors', 'kadence_blocks_colors', [ 'type' => 'string', 'description' => __( 'Config Kadence Blocks Color Palette', 'kadence-blocks' ), 'sanitize_callback' => 'sanitize_text_field', 'show_in_rest' => true, 'default' => '', ] ); register_setting( 'kadence_blocks_global', 'kadence_blocks_global', [ 'type' => 'string', 'description' => __( 'Config Kadence Blocks Global Settings', 'kadence-blocks' ), 'sanitize_callback' => 'sanitize_text_field', 'show_in_rest' => true, 'default' => '', ] ); register_setting( 'kadence_blocks_recaptcha_site_key', 'kadence_blocks_recaptcha_site_key', [ 'type' => 'string', 'description' => __( 'Google reCaptcha Site Key', 'kadence-blocks' ), 'sanitize_callback' => 'sanitize_text_field', 'show_in_rest' => true, 'default' => '', ] ); register_setting( 'kadence_blocks_recaptcha_secret_key', 'kadence_blocks_recaptcha_secret_key', [ 'type' => 'string', 'description' => __( 'Google reCaptcha Secret Key', 'kadence-blocks' ), 'sanitize_callback' => 'sanitize_text_field', 'show_in_rest' => true, 'default' => '', ] ); register_setting( 'kadence_blocks_recaptcha_language', 'kadence_blocks_recaptcha_language', [ 'type' => 'string', 'description' => __( 'Google reCaptcha Language', 'kadence-blocks' ), 'sanitize_callback' => 'sanitize_text_field', 'show_in_rest' => true, 'default' => '', ] ); register_setting( 'kadence_blocks_turnstile_site_key', 'kadence_blocks_turnstile_site_key', [ 'type' => 'string', 'description' => __( 'Cloudflare Turnstile Site Key', 'kadence-blocks' ), 'sanitize_callback' => 'sanitize_text_field', 'show_in_rest' => true, 'default' => '', ] ); register_setting( 'kadence_blocks_turnstile_secret_key', 'kadence_blocks_turnstile_secret_key', [ 'type' => 'string', 'description' => __( 'Cloudflare Turnstile Secret Key', 'kadence-blocks' ), 'sanitize_callback' => 'sanitize_text_field', 'show_in_rest' => true, 'default' => '', ] ); register_setting( 'kadence_blocks_hcaptcha_site_key', 'kadence_blocks_hcaptcha_site_key', [ 'type' => 'string', 'description' => __( 'hCaptcha Turnstile Site Key', 'kadence-blocks' ), 'sanitize_callback' => 'sanitize_text_field', 'show_in_rest' => true, 'default' => '', ] ); register_setting( 'kadence_blocks_hcaptcha_secret_key', 'kadence_blocks_hcaptcha_secret_key', [ 'type' => 'string', 'description' => __( 'hCaptcha Secret Key', 'kadence-blocks' ), 'sanitize_callback' => 'sanitize_text_field', 'show_in_rest' => true, 'default' => '', ] ); register_setting( 'kadence_blocks_mailerlite_api', 'kadence_blocks_mailerlite_api', [ 'type' => 'string', 'description' => __( 'MailerLite API Key', 'kadence-blocks' ), 'sanitize_callback' => 'sanitize_text_field', 'show_in_rest' => true, 'default' => '', ] ); register_setting( 'kadence_blocks_google_maps_api', 'kadence_blocks_google_maps_api', [ 'type' => 'string', 'description' => __( 'Google Maps API Key', 'kadence-blocks' ), 'sanitize_callback' => 'sanitize_text_field', 'show_in_rest' => true, 'default' => '', ] ); register_setting( 'kadence_blocks_cloud', 'kadence_blocks_cloud', [ 'type' => 'string', 'description' => __( 'Config Kadence Blocks Cloud', 'kadence-blocks' ), 'sanitize_callback' => 'sanitize_text_field', 'show_in_rest' => true, 'default' => '', ] ); register_setting( 'kadence_blocks_header_notice_dismissed', 'kadence_blocks_header_notice_dismissed', [ 'type' => 'boolean', 'description' => __( 'Is Kadence header notice dismissed', 'kadence-blocks' ), 'sanitize_callback' => 'rest_sanitize_boolean', 'show_in_rest' => true, 'default' => false, ] ); register_setting( 'kadence_blocks_wire_subscribe', 'kadence_blocks_wire_subscribe', [ 'type' => 'boolean', 'description' => __( 'Subscribe to Wireframe library', 'kadence-blocks' ), 'sanitize_callback' => 'rest_sanitize_boolean', 'show_in_rest' => true, 'default' => false, ] ); register_setting( 'kadence_blocks_convertkit_api', 'kadence_blocks_convertkit_api', [ 'type' => 'string', 'description' => __( 'ConvertKit API Key', 'kadence-blocks' ), 'sanitize_callback' => 'sanitize_text_field', 'show_in_rest' => true, 'default' => '', ] ); register_setting( 'kadence_blocks_activecampaign_api_key', 'kadence_blocks_activecampaign_api_key', [ 'type' => 'string', 'description' => __( 'ConvertKit API Key', 'kadence-blocks' ), 'sanitize_callback' => 'sanitize_text_field', 'show_in_rest' => true, 'default' => '', ] ); register_setting( 'kadence_blocks_activecampaign_api_base', 'kadence_blocks_activecampaign_api_base', [ 'type' => 'string', 'description' => __( 'ConvertKit API Key', 'kadence-blocks' ), 'sanitize_callback' => 'sanitize_text_field', 'show_in_rest' => true, 'default' => '', ] ); register_setting( 'kadence_blocks_header_popover_tutorial_complete', 'kadence_blocks_header_popover_tutorial_complete', [ 'type' => 'boolean', 'description' => __( 'Mark the Header popover tutorial Complete', 'kadence-blocks' ), 'sanitize_callback' => 'rest_sanitize_boolean', 'show_in_rest' => true, 'default' => false, ] ); } /** * Register settings */ public function load_settings() { register_setting( 'kt_blocks_editor_width', 'kt_blocks_editor_width', [ $this, 'validate_options' ] ); // Sidebar and No sidebar Max widths. add_settings_section( 'kt_blocks_editor_width_sec', '', [ $this, 'maxwidths_callback' ], 'kt_blocks_editor_width_section' ); add_settings_field( 'sidebar', __( 'Small Template', 'kadence-blocks' ), [ $this, 'sidebar_callback' ], 'kt_blocks_editor_width_section', 'kt_blocks_editor_width_sec' ); add_settings_field( 'nosidebar', __( 'Large Template', 'kadence-blocks' ), [ $this, 'nosidebar_callback' ], 'kt_blocks_editor_width_section', 'kt_blocks_editor_width_sec' ); // Defaults for Pages and posts. add_settings_field( 'post_default', __( 'Post default', 'kadence-blocks' ), [ $this, 'post_default_callback' ], 'kt_blocks_editor_width_section', 'kt_blocks_editor_width_sec' ); add_settings_field( 'page_default', __( 'Page Default', 'kadence-blocks' ), [ $this, 'page_default_callback' ], 'kt_blocks_editor_width_section', 'kt_blocks_editor_width_sec' ); // add_settings_field( 'limited_margins', __( 'Enable Less Margin CSS', 'kadence-blocks' ), array( $this, 'limited_margins_callback' ), 'kt_blocks_editor_width_section', 'kt_blocks_editor_width_sec' ); add_settings_field( 'enable_editor_width', __( 'Enable Editor Width', 'kadence-blocks' ), [ $this, 'enabled_editor_width_callback' ], 'kt_blocks_editor_width_section', 'kt_blocks_editor_width_sec' ); if ( ! defined( 'KADENCE_VERSION' ) ) { register_setting( 'kadence_blocks_font_settings', 'kadence_blocks_font_settings', [ $this, 'validate_options' ] ); add_settings_section( 'kt_blocks_fonts_sec', '', [ $this, 'fonts_local_callback' ], 'kt_blocks_fonts_section' ); add_settings_field( 'load_fonts_local', __( 'Load Google Fonts Locally', 'kadence-blocks' ), [ $this, 'load_fonts_local_callback' ], 'kt_blocks_fonts_section', 'kt_blocks_fonts_sec' ); } } /** * Outputs Sidebar number field */ public function enabled_editor_width_callback() { $data = self::get_data_options( 'kt_blocks_editor_width' ); $default_enabled = ( $data['enable_editor_width'] ?? 'true' ); echo '' . esc_html__( 'Allows for changes to the editor width on per page/post basis with preset defaults.', 'kadence-blocks' ) . '
'; echo ''; } /** * Outputs Limited Margins Field */ public function limited_margins_callback() { $data = self::get_data_options( 'kt_blocks_editor_width' ); $default_limited = ( $data['limited_margins'] ?? 'false' ); echo '
' . esc_html__( 'Experimental editor CSS for less excess margins in Gutenberg in an attempt to get a closer WYSIWYG editing experience.', 'kadence-blocks' ) . '
'; echo ''; } /** * Outputs Sidebar number field */ public function sidebar_callback() { $data = self::get_data_options( 'kt_blocks_editor_width' ); $default = apply_filters( 'kadence_blocks_default_small_editor_width', '750' ); echo ""; echo '' . esc_html__( 'px', 'kadence-blocks' ) . ''; } /** * Outputs no sidebar number field */ public function nosidebar_callback() { $data = self::get_data_options( 'kt_blocks_editor_width' ); $default = apply_filters( 'kadence_blocks_default_large_editor_width', '1140' ); echo ""; echo '' . esc_html__( 'px', 'kadence-blocks' ) . ''; } /** * Outputs post default select feild */ public function post_default_callback() { $data = self::get_data_options( 'kt_blocks_editor_width' ); $default_post_type = ( $data['post_default'] ?? 'sidebar' ); echo ''; } /** * Outputs post default select feild */ public function page_default_callback() { $data = self::get_data_options( 'kt_blocks_editor_width' ); $default_page_type = ( $data['page_default'] ?? 'sidebar' ); echo ''; } /** * Outputs font settings field */ public function load_fonts_local_callback() { $data = self::get_data_options( 'kadence_blocks_font_settings' ); $default = ( $data['load_fonts_local'] ?? 'false' ); echo ''; } /** * Outputs title for content width. */ public function maxwidths_callback() { // global $content_width; // echo '
' . wp_kses_post( $block['desc'] ) . '
'; echo ' '; echo '