get_upgrade_notice( '3.0.9' ); echo apply_filters( 'kadence_blocks_in_plugin_update_message', $upgrade_notice ? wp_kses_post( $upgrade_notice ) . '
'; $upgrade_notice .= preg_replace( '~\[([^\]]*)\]\(([^\)]*)\)~', '${1}', $notices[0] ); $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 '

' . esc_html__( 'Assign Editor Template Max Widths', 'kadence-blocks' ) . '
'; // echo '
' . esc_html__( 'Note: The current active themes "$content_width" is set to:', 'kadence-blocks' ) . ' ' . esc_html( $content_width ) . 'px
'; } /** * Outputs title for fonts local. */ public function fonts_local_callback() { } /** * Sanitizes and validates all input and output for Dashboard. * * @param array $input settings input. */ public function validate_options( $input ) { return $input; } /** * Checks for kadence classic themes when returning defualt. */ public function show_editor_width() { if ( is_null( self::$editor_width ) ) { $show = false; $current_theme = wp_get_theme(); $current_theme_name = $current_theme->get( 'Name' ); $current_theme_template = $current_theme->get( 'Template' ); // Check for a kadence classic theme support. if ( 'Pinnacle' == $current_theme_name || 'pinnacle' == $current_theme_template || 'Pinnacle Premium' == $current_theme_name || 'pinnacle_premium' == $current_theme_template || 'Ascend - Premium' == $current_theme_name || 'ascend_premium' == $current_theme_template || 'Ascend' == $current_theme_name || 'ascend' == $current_theme_template || 'Virtue - Premium' == $current_theme_name || 'virtue_premium' == $current_theme_template || 'Virtue' == $current_theme_name || 'virtue' == $current_theme_template ) { $show = true; } self::$editor_width = $show; } return self::$editor_width; } /** * Loads config page */ public function home_page() { do_action( 'stellarwp/telemetry/kadence-blocks/optin' ); ?>

blocks_array(); $unregistered_blocks = get_option( 'kt_blocks_unregistered_blocks', [] ); if ( ! is_array( $unregistered_blocks ) ) { $unregistered_blocks = []; } foreach ( $blocks as $block_key => $block ) { if ( in_array( $block['slug'], $unregistered_blocks ) ) { $btn_enabled_class = 'button-primary kt-block-inactive'; $enabled_class = 'kt-block-inactive'; } else { $btn_enabled_class = 'kt-block-active'; $enabled_class = 'kt-block-active'; } echo '
'; echo '

' . esc_html( $block['name'] ) . '

'; echo '

' . wp_kses_post( $block['desc'] ) . '

'; echo ''; echo '
'; } ?>
show_editor_width() ) ) { ?>


px
'; settings_fields( 'kt_blocks_editor_width' ); do_settings_sections( 'kt_blocks_editor_width_section' ); do_settings_sections( 'kt_blocks_editor_defaults_section' ); submit_button( __( 'Save Changes', 'kadence-blocks' ) ); echo ''; ?>

'; settings_fields( 'kadence_blocks_font_settings' ); do_settings_sections( 'kt_blocks_fonts_section' ); submit_button( __( 'Save Changes', 'kadence-blocks' ) ); echo ''; ?>
[ 'slug' => 'kadence/rowlayout', 'name' => __( 'Row Layout', 'kadence-blocks' ), 'desc' => __( 'Create rows with nested blocks either in columns or as a container. Give style to your rows with background, overlay, padding, etc.', 'kadence-blocks' ), ], 'kadence/form' => [ 'slug' => 'kadence/form', 'name' => __( 'Form', 'kadence-blocks' ), 'desc' => __( 'Create a contact form or marketing form and style it within the block editor.', 'kadence-blocks' ), ], 'kadence/advancedgallery' => [ 'slug' => 'kadence/advancedgallery', 'name' => __( 'Advanced Gallery', 'kadence-blocks' ), 'desc' => __( 'Photo galleries, carousels, and sliders! Enable custom links, captions, and more. Plus, you can select image sizes.', 'kadence-blocks' ), ], 'kadence/advancedbtn' => [ 'slug' => 'kadence/advancedbtn', 'name' => __( 'Advanced Button', 'kadence-blocks' ), 'desc' => __( 'Create an advanced button or a row of buttons. Style each one including hover controls plus you can use an icon and display them side by side', 'kadence-blocks' ), ], 'kadence/lottie' => [ 'slug' => 'kadence/lottie', 'name' => __( 'Lottie Animations', 'kadence-blocks' ), 'desc' => __( 'Add an extra "wow" factor to your site with engaging Lottie animations.', 'kadence-blocks' ), 'link' => admin_url( 'edit.php?post_type=kadence_lottie' ), 'linkText' => __( 'Manage Lottie Animations', 'kadence-blocks' ), ], 'kadence/vector' => [ 'slug' => 'kadence/vector', 'name' => __( 'Vector Graphics', 'kadence-blocks' ), 'desc' => __( 'Add custom vector icons and SVGs to enhance your site design.', 'kadence-blocks' ), 'link' => admin_url( 'edit.php?post_type=kadence_vector' ), 'linkText' => __( 'Manage Vector Graphics', 'kadence-blocks' ), ], 'kadence/header' => [ 'slug' => 'kadence/header', 'name' => __( 'Advanced Header', 'kadence-blocks' ), 'desc' => __( 'Build custom headers in the block editor and full site editing.', 'kadence-blocks' ), 'link' => admin_url( 'edit.php?post_type=kadence_header' ), 'linkText' => __( 'Manage Headers', 'kadence-blocks' ), ], 'kadence/navigation' => [ 'slug' => 'kadence/navigation', 'name' => __( 'Advanced Navigation', 'kadence-blocks' ), 'desc' => __( 'Build custom navigation menus', 'kadence-blocks' ), 'link' => admin_url( 'edit.php?post_type=kadence_navigation' ), 'linkText' => __( 'Manage Navigation Menus', 'kadence-blocks' ), ], 'kadence/icon' => [ 'slug' => 'kadence/icon', 'name' => __( 'Icon', 'kadence-blocks' ), 'desc' => __( 'Choose from over 1500+ SVG Icons to add into your page and style the size, colors, background, border, etc.', 'kadence-blocks' ), ], 'kadence/spacer' => [ 'slug' => 'kadence/spacer', 'name' => __( 'Spacer/Divider', 'kadence-blocks' ), 'desc' => __( 'Easily create a divider and determine the space around it or just create some space in your content.', 'kadence-blocks' ), ], 'kadence/advancedheading' => [ 'slug' => 'kadence/advancedheading', 'name' => __( 'Advanced Text', 'kadence-blocks' ), 'desc' => __( 'Create a heading or paragraph and define sizes for desktop, tablet and mobile along with font family, colors, etc.', 'kadence-blocks' ), ], 'kadence/tabs' => [ 'slug' => 'kadence/tabs', 'name' => __( 'Tabs', 'kadence-blocks' ), 'desc' => __( 'Create custom vertical or horizontal tabs with advanced styling controls. Each tab content is an empty canvas able to contain any other blocks.', 'kadence-blocks' ), ], 'kadence/infobox' => [ 'slug' => 'kadence/infobox', 'name' => __( 'Info Box', 'kadence-blocks' ), 'desc' => __( 'Create a box containing an icon or image and, optionally, a title, description, and learn more text. Style static and hover separately.', 'kadence-blocks' ), ], 'kadence/accordion' => [ 'slug' => 'kadence/accordion', 'name' => __( 'Accordion', 'kadence-blocks' ), 'desc' => __( 'Create beautiful accordions! Each pane can contain any other block, customize title styles, content background, and borders.', 'kadence-blocks' ), ], 'kadence/iconlist' => [ 'slug' => 'kadence/iconlist', 'name' => __( 'Icon List', 'kadence-blocks' ), 'desc' => __( 'Add beautiful icons to your lists and make them more engaging. Over 1500 icons to choose from and unlimited styles.', 'kadence-blocks' ), ], 'kadence/tableofcontents' => [ 'slug' => 'kadence/tableofcontents', 'name' => __( 'Table of Contents', 'kadence-blocks' ), 'desc' => __( 'Allow your readers to navigate your content easily with a table of contents block. Includes smooth scroll to anchor.', 'kadence-blocks' ), ], 'kadence/posts' => [ 'slug' => 'kadence/posts', 'name' => __( 'Posts', 'kadence-blocks' ), 'desc' => __( 'Display a clean grid of posts anywhere on your site, great for your home page where you want to tease your blog.', 'kadence-blocks' ), ], 'kadence/countdown' => [ 'slug' => 'kadence/countdown', 'name' => __( 'Countdown', 'kadence-blocks' ), 'desc' => __( 'Increase your conversions by adding a sense of urgency to your offering. Pro includes evergreen campaigns as well.', 'kadence-blocks' ), ], 'kadence/testimonials' => [ 'slug' => 'kadence/testimonials', 'name' => __( 'Testimonials', 'kadence-blocks' ), 'desc' => __( 'Create confidence in your brand or product by showing off beautiful unique testimonials, add as a carousel or a grid.', 'kadence-blocks' ), ], ]; // for blocks moved from pro to free if ( ! defined( 'KBP_VERSION' ) || ( defined( 'KBP_VERSION' ) && version_compare( KBP_VERSION, '2.6.0', '>' ) ) ) { $blocks['kadence/videopopup'] = [ 'slug' => 'kadence/videopopup', 'name' => __( 'Video Popup', 'kadence-blocks' ), 'desc' => __( 'Beautifully display a thumbnail with overlay and hover effect that links to a video popup on click. Works with local or external videos!', 'kadence-blocks' ), 'image' => KADENCE_BLOCKS_URL . 'includes/settings/img/block-video-pop.jpg', ]; } return apply_filters( 'kadence_blocks_enable_disable_array', $blocks ); } /** * Ajax Save blocks Config */ public function ajax_blocks_save_config() { if ( ! check_ajax_referer( 'kadence-blocks-manage', 'wpnonce' ) ) { wp_send_json_error( __( 'Invalid nonce', 'kadence-blocks' ) ); } if ( ! isset( $_POST['kt_block'] ) && ! isset( $_POST['config'] ) ) { return wp_send_json_error( __( 'Missing Content', 'kadence-blocks' ) ); } // Get settings. $current_settings = get_option( 'kt_blocks_config_blocks' ); $new_settings = wp_unslash( $_POST['config'] ); if ( ! is_array( $new_settings ) ) { return wp_send_json_error( __( 'Nothing to Save', 'kadence-blocks' ) ); } foreach ( $new_settings as $block_key => $settings ) { foreach ( $settings as $attribute_key => $value ) { if ( is_array( $value ) ) { foreach ( $value as $array_attribute_index => $array_value ) { if ( is_array( $array_value ) ) { foreach ( $array_value as $array_attribute_key => $array_attribute_value ) { $array_attribute_value = sanitize_text_field( $array_attribute_value ); if ( is_numeric( $array_attribute_value ) ) { $array_attribute_value = floatval( $array_attribute_value ); } if ( 'true' === $array_attribute_value ) { $array_attribute_value = true; } if ( 'false' === $array_attribute_value ) { $array_attribute_value = false; } $new_settings[ $block_key ][ $attribute_key ][ $array_attribute_index ][ $array_attribute_key ] = $array_attribute_value; } } else { $array_value = sanitize_text_field( $array_value ); if ( is_numeric( $array_value ) ) { $array_value = floatval( $array_value ); } $new_settings[ $block_key ][ $attribute_key ][ $array_attribute_index ] = $array_value; } } } else { $value = sanitize_text_field( $value ); if ( is_numeric( $value ) ) { $value = floatval( $value ); } if ( 'true' === $value ) { $value = true; } if ( 'false' === $value ) { $value = false; } $new_settings[ $block_key ][ $attribute_key ] = $value; } } } $block = sanitize_text_field( wp_unslash( $_POST['kt_block'] ) ); if ( ! is_array( $current_settings ) ) { $current_settings = []; } $current_settings[ $block ] = $new_settings[ $block ]; update_option( 'kt_blocks_config_blocks', $current_settings ); return wp_send_json_success(); } /** * Ajax activate/deactivate blocks */ public function ajax_blocks_activate_deactivate() { if ( ! check_ajax_referer( 'kadence-blocks-manage', 'wpnonce' ) ) { wp_send_json_error(); } if ( ! isset( $_POST['kt_block'] ) ) { return wp_send_json_error(); } // Get variables. $unregistered_blocks = get_option( 'kt_blocks_unregistered_blocks' ); $block = sanitize_text_field( wp_unslash( $_POST['kt_block'] ) ); if ( ! is_array( $unregistered_blocks ) ) { $unregistered_blocks = []; } // If current block is in the array - remove it. if ( in_array( $block, $unregistered_blocks ) ) { $index = array_search( $block, $unregistered_blocks ); if ( false !== $index ) { unset( $unregistered_blocks[ $index ] ); } // if current block is not in the array - add it. } else { array_push( $unregistered_blocks, $block ); } update_option( 'kt_blocks_unregistered_blocks', $unregistered_blocks ); return wp_send_json_success(); } /** * Ajax default posts width */ public function ajax_default_editor_width() { if ( ! check_ajax_referer( 'kadence-blocks-manage', 'wpnonce' ) ) { wp_send_json_error(); } if ( ! isset( $_POST['post_default'] ) ) { return wp_send_json_error(); } // Get variables. $editor_widths = get_option( 'kt_blocks_editor_width' ); $default = sanitize_text_field( wp_unslash( $_POST['post_default'] ) ); if ( ! is_array( $editor_widths ) ) { $editor_widths = []; } $editor_widths['post_default'] = $default; update_option( 'kt_blocks_editor_width', $editor_widths ); return wp_send_json_success(); } /** * Add settings link */ public function settings_link() { return apply_filters( 'kadence-blocks-settings-url', admin_url( 'admin.php?page=kadence-blocks' ) ); } /** * Add settings link * * @param array $links plugin activate/deactivate links array. */ public function add_settings_link( $links ) { $settings_link = '' . __( 'Settings', 'kadence-blocks' ) . ''; array_push( $links, $settings_link ); return $links; } } Kadence_Blocks_Settings::get_instance();