芝麻web文件管理V1.00
编辑当前文件:/home/r5772835/public_html/ycreate.jp/wp-content/plugins/snow-monkey-editor/snow-monkey-editor.php
roles, true ) || 'sme-guest' === $role && ! $user->roles ) { return ''; } } } return $content; } /** * Apply datetime setting to blocks. * * @param string $content The block content about to be appended. * @param array $block The full block, including name and attributes. * @return string */ public function _date_time( $content, $block ) { if ( ! isset( $block['attrs'] ) ) { return $content; } // Dates entered in the block editor are localized. $attributes = $block['attrs']; $start_date_time = isset( $attributes['smeStartDateTime'] ) ? $attributes['smeStartDateTime'] : false; $end_date_time = isset( $attributes['smeEndDateTime'] ) ? $attributes['smeEndDateTime'] : false; if ( ! $start_date_time && ! $end_date_time ) { return $content; } $current_date_time = wp_date( 'Y-m-d\TH:i:s' ); $current_date_time = strtotime( $current_date_time ); if ( $start_date_time ) { $start_date_time = strtotime( $start_date_time ); if ( $start_date_time > $current_date_time ) { return ''; } } if ( $end_date_time ) { $end_date_time = strtotime( $end_date_time ); if ( $end_date_time < $current_date_time ) { return ''; } } return $content; } /** * Set counter to ordered list. * * @param string $content The block content about to be appended. * @param array $block The full block, including name and attributes. * @return string */ public function _ordered_list_counter( $content, $block ) { if ( 'core/list' !== $block['blockName'] ) { return $content; } if ( ! isset( $block['attrs'] ) ) { return $content; } $attributes = $block['attrs']; $class_name = isset( $attributes['className'] ) ? $attributes['className'] : false; if ( ! $class_name || ! isset( $attributes['ordered'] ) ) { return $content; } $is_ol_circle = strpos( $class_name, 'is-style-sme-ordered-list-circle' ); $is_ol_square = strpos( $class_name, 'is-style-sme-ordered-list-square' ); if ( false !== $is_ol_circle || false !== $is_ol_square ) { $start = ! empty( $attributes['start'] ) ? $attributes['start'] : 1; $sme_count = ! empty( $attributes['reversed'] ) ? 'sme-count ' . ( $start + 1 ) : 'sme-count ' . ( $start - 1 ); $content = preg_replace( '|^
= $delay ) { return $content; } return preg_replace( '|(\/?>)|ms', ' data-sme-animation-delay="' . esc_attr( $delay ) . '"$1', $content, 1 ); } /** * Set animation duration * * @param string $content The block content about to be appended. * @param array $block The full block, including name and attributes. * @return string */ public function _animation_duration( $content, $block ) { if ( ! isset( $block['attrs'] ) ) { return $content; } $attributes = $block['attrs']; $duration = isset( $attributes['smeAnimationDuration'] ) ? $attributes['smeAnimationDuration'] : false; if ( 0 >= $duration ) { return $content; } return preg_replace( '|(\/?>)|ms', ' data-sme-animation-duration="' . esc_attr( $duration ) . '"$1', $content, 1 ); } /** * Adds attributes to all blocks, to avoid `Invalid parameter(s): attributes` error in Gutenberg. * * @see https://github.com/Codeinwp/gutenberg-animation/blob/a0efe29a3ce023e0f562bb9a51d34b345431b642/class-gutenberg-animation.php#L105-L119 */ public function _add_attributes_to_blocks() { $attributes = array(); foreach ( glob( SNOW_MONKEY_EDITOR_PATH . '/src/extension/*', GLOB_ONLYDIR ) as $dir ) { foreach ( glob( $dir . '/attributes.json' ) as $file ) { $_attributes = file_get_contents( $file ); $_attributes = json_decode( $_attributes, true ); $attributes = array_merge( $attributes, $_attributes ); } } $registered_blocks = WP_Block_Type_Registry::get_instance()->get_all_registered(); foreach ( $registered_blocks as $name => $block ) { if ( ! isset( $block->attributes ) || ! is_array( $block->attributes ) ) { $block->attributes = array(); } foreach ( $attributes as $name => $detail ) { $block->attributes[ $name ] = $detail; } } } } new \Snow_Monkey\Plugin\Editor\Bootstrap();