render_block_data` instead.' ) ); } $block_type = WP_Block_Type_Registry::get_instance()->get_registered( $parsed_block['blockName'] ); $element_block_styles = isset( $parsed_block['attrs']['style']['elements'] ) ? $parsed_block['attrs']['style']['elements'] : null; if ( ! $element_block_styles ) { return $parsed_block; } $skip_link_color_serialization = wp_should_skip_block_supports_serialization( $block_type, 'color', 'link' ); $skip_heading_color_serialization = wp_should_skip_block_supports_serialization( $block_type, 'color', 'heading' ); $skip_button_color_serialization = wp_should_skip_block_supports_serialization( $block_type, 'color', 'button' ); $skips_all_element_color_serialization = $skip_link_color_serialization && $skip_heading_color_serialization && $skip_button_color_serialization; if ( $skips_all_element_color_serialization ) { return $parsed_block; } $options = array( 'button' => array( 'skip' => $skip_button_color_serialization ), 'link' => array( 'skip' => $skip_link_color_serialization ), 'heading' => array( 'skip' => $skip_heading_color_serialization ), ); if ( ! wp_should_add_elements_class_name( $parsed_block, $options ) ) { return $parsed_block; } $class_name = wp_get_elements_class_name( $parsed_block ); $updated_class_name = isset( $parsed_block['attrs']['className'] ) ? $parsed_block['attrs']['className'] . " $class_name" : $class_name; _wp_array_set( $parsed_block, array( 'attrs', 'className' ), $updated_class_name ); // Generate element styles based on selector and store in style engine for enqueuing. $element_types = array( 'button' => array( 'selector' => ".$class_name .wp-element-button, .$class_name .wp-block-button__link", 'skip' => $skip_button_color_serialization, ), 'link' => array( 'selector' => ".$class_name a:where(:not(.wp-element-button))", 'hover_selector' => ".$class_name a:where(:not(.wp-element-button)):hover", 'skip' => $skip_link_color_serialization, ), 'heading' => array( 'selector' => ".$class_name h1, .$class_name h2, .$class_name h3, .$class_name h4, .$class_name h5, .$class_name h6", 'skip' => $skip_heading_color_serialization, 'elements' => array( 'h1', 'h2', 'h3', 'h4', 'h5', 'h6' ), ), ); foreach ( $element_types as $element_type => $element_config ) { if ( $element_config['skip'] ) { continue; } $element_style_object = isset( $element_block_styles[ $element_type ] ) ? $element_block_styles[ $element_type ] : null; // Process primary element type styles. if ( $element_style_object ) { wp_style_engine_get_styles( $element_style_object, array( 'selector' => $element_config['selector'], 'context' => 'block-supports', ) ); if ( isset( $element_style_object[':hover'] ) ) { wp_style_engine_get_styles( $element_style_object[':hover'], array( 'selector' => $element_config['hover_selector'], 'context' => 'block-supports', ) ); } } // Process related elements e.g. h1-h6 for headings. if ( isset( $element_config['elements'] ) ) { foreach ( $element_config['elements'] as $element ) { $element_style_object = isset( $element_block_styles[ $element ] ) ? $element_block_styles[ $element ] : null; if ( $element_style_object ) { wp_style_engine_get_styles( $element_style_object, array( 'selector' => ".$class_name $element", 'context' => 'block-supports', ) ); } } } } return $parsed_block; } /** * Ensure the elements block support class name generated, and added to * block attributes, in the `render_block_data` filter gets applied to the * block's markup. * * @see wp_render_elements_support_styles * @since 6.6.0 * * @param string $block_content Rendered block content. * @param array $block Block object. * @return string Filtered block content. */ function wp_render_elements_class_name( $block_content, $block ) { $class_string = $block['attrs']['className'] ?? ''; preg_match( '/\bwp-elements-\S+\b/', $class_string, $matches ); if ( empty( $matches ) ) { return $block_content; } $tags = new WP_HTML_Tag_Processor( $block_content ); if ( $tags->next_tag() ) { $tags->add_class( $matches[0] ); } return $tags->get_updated_html(); } add_filter( 'render_block', 'wp_render_elements_class_name', 10, 2 ); add_filter( 'render_block_data', 'wp_render_elements_support_styles', 10, 1 ); nk text by using the "puc_manual_check_link-$slug" filter. * Returning an empty string from the filter will disable the link. * * @param array $pluginMeta Array of meta links. * @param string $pluginFile * @return array */ public function addCheckForUpdatesLink($pluginMeta, $pluginFile) { if ( $this->isMyPluginFile($pluginFile) ) { $linkUrl = wp_nonce_url( add_query_arg( array( 'puc_check_for_updates' => 1, 'puc_slug' => $this->updateChecker->slug, ), self_admin_url('plugins.php') ), 'puc_check_for_updates' ); $linkText = apply_filters( $this->updateChecker->getUniqueName('manual_check_link'), __('Check for updates', 'plugin-update-checker') ); if ( !empty($linkText) ) { /** @noinspection HtmlUnknownTarget */ $pluginMeta[] = sprintf('%s', esc_attr($linkUrl), $linkText); } } return $pluginMeta; } protected function isMyPluginFile($pluginFile) { return ($pluginFile == $this->updateChecker->pluginFile) || (!empty($this->updateChecker->muPluginFile) && ($pluginFile == $this->updateChecker->muPluginFile)); } /** * Check for updates when the user clicks the "Check for updates" link. * * @see self::addCheckForUpdatesLink() * * @return void */ public function handleManualCheck() { $shouldCheck = isset($_GET['puc_check_for_updates'], $_GET['puc_slug']) && $_GET['puc_slug'] == $this->updateChecker->slug && check_admin_referer('puc_check_for_updates'); if ( $shouldCheck ) { $update = $this->updateChecker->checkForUpdates(); $status = ($update === null) ? 'no_update' : 'update_available'; if ( ($update === null) && !empty($this->lastRequestApiErrors) ) { //Some errors are not critical. For example, if PUC tries to retrieve the readme.txt //file from GitHub and gets a 404, that's an API error, but it doesn't prevent updates //from working. Maybe the plugin simply doesn't have a readme. //Let's only show important errors. $foundCriticalErrors = false; $questionableErrorCodes = array( 'puc-github-http-error', 'puc-gitlab-http-error', 'puc-bitbucket-http-error', ); foreach ($this->lastRequestApiErrors as $item) { $wpError = $item['error']; /** @var WP_Error $wpError */ if ( !in_array($wpError->get_error_code(), $questionableErrorCodes) ) { $foundCriticalErrors = true; break; } } if ( $foundCriticalErrors ) { $status = 'error'; set_site_transient($this->manualCheckErrorTransient, $this->lastRequestApiErrors, 60); } } wp_redirect(add_query_arg( array( 'puc_update_check_result' => $status, 'puc_slug' => $this->updateChecker->slug, ), self_admin_url('plugins.php') )); exit; } } /** * Display the results of a manual update check. * * @see self::handleManualCheck() * * You can change the result message by using the "puc_manual_check_message-$slug" filter. */ public function displayManualCheckResult() { if ( isset($_GET['puc_update_check_result'], $_GET['puc_slug']) && ($_GET['puc_slug'] == $this->updateChecker->slug) ) { $status = strval($_GET['puc_update_check_result']); $title = $this->updateChecker->getInstalledPackage()->getPluginTitle(); $noticeClass = 'updated notice-success'; $details = ''; if ( $status == 'no_update' ) { $message = sprintf(_x('The %s plugin is up to date.', 'the plugin title', 'plugin-update-checker'), $title); } else if ( $status == 'update_available' ) { $message = sprintf(_x('A new version of the %s plugin is available.', 'the plugin title', 'plugin-update-checker'), $title); } else if ( $status === 'error' ) { $message = sprintf(_x('Could not determine if updates are available for %s.', 'the plugin title', 'plugin-update-checker'), $title); $noticeClass = 'error notice-error'; $details = $this->formatManualCheckErrors(get_site_transient($this->manualCheckErrorTransient)); delete_site_transient($this->manualCheckErrorTransient); } else { $message = sprintf(__('Unknown update checker status "%s"', 'plugin-update-checker'), htmlentities($status)); $noticeClass = 'error notice-error'; } printf( '

%s

%s
', $noticeClass, apply_filters($this->updateChecker->getUniqueName('manual_check_message'), $message, $status), $details ); } } /** * Format the list of errors that were thrown during an update check. * * @param array $errors * @return string */ protected function formatManualCheckErrors($errors) { if ( empty($errors) ) { return ''; } $output = ''; $showAsList = count($errors) > 1; if ( $showAsList ) { $output .= '
    '; $formatString = '
  1. %1$s %2$s
  2. '; } else { $formatString = '

    %1$s %2$s

    '; } foreach ($errors as $item) { $wpError = $item['error']; /** @var WP_Error $wpError */ $output .= sprintf( $formatString, $wpError->get_error_message(), $wpError->get_error_code() ); } if ( $showAsList ) { $output .= '
'; } return $output; } public function removeHooks() { remove_action('admin_init', array($this, 'onAdminInit')); remove_filter('plugin_row_meta', array($this, 'addViewDetailsLink'), 10); remove_filter('plugin_row_meta', array($this, 'addCheckForUpdatesLink'), 10); remove_action('all_admin_notices', array($this, 'displayManualCheckResult')); } } endif;
Fatal error: Uncaught Error: Class "Puc_v4p4_Plugin_Ui" not found in /htdocs/le-blog.fr/wp-content/plugins/le-blog/lib/plugin-update-checker/Puc/v4p4/Plugin/UpdateChecker.php:71 Stack trace: #0 /htdocs/le-blog.fr/wp-content/plugins/le-blog/lib/plugin-update-checker/Puc/v4p4/Vcs/PluginUpdateChecker.php(29): Puc_v4p4_Plugin_UpdateChecker->__construct('https://github....', '/htdocs/le-blog...', 'isubmission', 12, '', '') #1 /htdocs/le-blog.fr/wp-content/plugins/le-blog/lib/plugin-update-checker/Puc/v4p4/Factory.php(99): Puc_v4p4_Vcs_PluginUpdateChecker->__construct(Object(Puc_v4p4_Vcs_GitHubApi), '/htdocs/le-blog...', 'isubmission', 12, '', '') #2 /htdocs/le-blog.fr/wp-content/plugins/le-blog/isubmission.php(58): Puc_v4p4_Factory::buildUpdateChecker('https://github....', '/htdocs/le-blog...', 'isubmission') #3 /htdocs/le-blog.fr/wp-content/plugins/le-blog/isubmission.php(21): Isubmission->run_update_checker() #4 /htdocs/le-blog.fr/wp-content/plugins/le-blog/isubmission.php(66): Isubmission->__construct() #5 /htdocs/le-blog.fr/wp-settings.php(560): include_once('/htdocs/le-blog...') #6 /htdocs/le-blog.fr/wp-config.php(102): require_once('/htdocs/le-blog...') #7 /htdocs/le-blog.fr/wp-load.php(50): require_once('/htdocs/le-blog...') #8 /htdocs/le-blog.fr/wp-blog-header.php(13): require_once('/htdocs/le-blog...') #9 /htdocs/le-blog.fr/index.php(17): require('/htdocs/le-blog...') #10 {main} thrown in /htdocs/le-blog.fr/wp-content/plugins/le-blog/lib/plugin-update-checker/Puc/v4p4/Plugin/UpdateChecker.php on line 71