芝麻web文件管理V1.00
编辑当前文件:/var/www/cognitio.in/wp-content/plugins/popup-maker/classes/Admin/Shortcode/UI.php
wp_create_nonce( 'pum-shortcode-ui-nonce' ), 'I10n' => [ 'insert' => __( 'Insert', 'popup-maker' ), 'cancel' => __( 'Cancel', 'popup-maker' ), 'shortcode_ui_button_tooltip' => __( 'Popup Maker Shortcodes', 'popup-maker' ), 'error_loading_shortcode_preview' => __( 'There was an error in generating the preview', 'popup-maker' ), ], 'shortcodes' => self::shortcode_ui_var(), ] ) ); } /** * Generates a json object variable to pass to the Shortcode UI front end. * * @return array */ public static function shortcode_ui_var() { $type = pum_typenow(); $shortcodes = []; foreach ( PUM_Shortcodes::instance()->get_shortcodes() as $tag => $shortcode ) { $post_types = apply_filters( 'pum_shortcode_post_types', $shortcode->post_types(), $shortcode ); /** * @var $shortcode PUM_Shortcode */ if ( ! in_array( '*', $post_types ) && ! in_array( $type, $post_types ) ) { continue; } $shortcodes[ $tag ] = [ 'version' => $shortcode->version, 'label' => $shortcode->label(), 'description' => $shortcode->description(), 'tabs' => $shortcode->_tabs(), 'sections' => $shortcode->_subtabs(), 'fields' => $shortcode->_fields(), 'has_content' => $shortcode->has_content, 'ajax_rendering' => $shortcode->ajax_rendering, ]; } return $shortcodes; } /** * Adds our tinymce plugin js * * @param array $plugin_array * * @return array */ public static function mce_external_plugins( $plugin_array ) { return array_merge( $plugin_array, [ 'pum_shortcodes' => add_query_arg( [ 'version' => Popup_Maker::$VER ], PUM_Admin_Assets::$js_url . 'mce-buttons' . PUM_Admin_Assets::$suffix . '.js' ), ] ); } public static function do_shortcode() { check_ajax_referer( 'pum-shortcode-ui-nonce', 'nonce' ); $tag = ! empty( $_REQUEST['tag'] ) ? sanitize_key( $_REQUEST['tag'] ) : false; $shortcode = ! empty( $_REQUEST['shortcode'] ) ? stripslashes( sanitize_text_field( $_REQUEST['shortcode'] ) ) : null; $post_id = isset( $_REQUEST['post_id'] ) ? intval( $_REQUEST['post_id'] ) : null; if ( ! current_user_can( 'edit_post', $post_id ) ) { return esc_html__( 'You do not have access to preview this post.', 'popup-maker' ); } /** @var PUM_Shortcode $shortcode */ $shortcode_object = PUM_Shortcodes::instance()->get_shortcode( $tag ); if ( ! defined( 'PUM_DOING_PREVIEW' ) ) { define( 'PUM_DOING_PREVIEW', true ); } /** * Often the global $post is not set yet. Set it in case for proper rendering. */ if ( ! empty( $post_id ) ) { global $post; $post = get_post( $post_id ); setup_postdata( $post ); } /** @var string $content Rendered shortcode content. */ $content = PUM_Helpers::do_shortcode( $shortcode ); /** If no matching tag or $content wasn't rendered die. */ if ( ! $shortcode_object || $content === $shortcode ) { wp_send_json_error(); } /** Generate inline styles when needed. */ $styles = ''; wp_send_json_success( $styles . $content ); } }