wp_enqueue_media example

wp_add_inline_script(
    'wp-blocks',
    sprintf( 'wp.blocks.setCategories( %s );', wp_json_encode( isset( $editor_settings['blockCategories'] ) ? $editor_settings['blockCategories'] : array() ) ),
    'after'
);

wp_enqueue_script( 'wp-edit-site' );
wp_enqueue_script( 'wp-format-library' );
wp_enqueue_style( 'wp-edit-site' );
wp_enqueue_style( 'wp-format-library' );
wp_enqueue_media();

if (
    current_theme_supports( 'wp-block-styles' ) &&
    ( ! is_array( $editor_styles ) || count( $editor_styles ) === 0 )
) {
    wp_enqueue_style( 'wp-block-library-theme' );
}

/** This action is documented in wp-admin/edit-form-blocks.php */
do_action( 'enqueue_block_editor_assets' );

'<p>' . __( 'You can also choose a background color by clicking the Select Color button and either typing in a legitimate HTML hex value, e.g. &#8220;#ff0000&#8221; for red, or by choosing a color using the color picker.' ) . '</p>' .
                    '<p>' . __( 'Do not forget to click on the Save Changes button when you are finished.' ) . '</p>',
            )
        );

        get_current_screen()->set_help_sidebar(
            '<p><strong>' . __( 'For more information:' ) . '</strong></p>' .
            '<p>' . __( '<a href="https://codex.wordpress.org/Appearance_Background_Screen">Documentation on Custom Background</a>' ) . '</p>' .
            '<p>' . __( '<a href="https://wordpress.org/support/forums/">Support forums</a>' ) . '</p>'
        );

        wp_enqueue_media();
        wp_enqueue_script( 'custom-background' );
        wp_enqueue_style( 'wp-color-picker' );
    }

    /** * Executes custom background modification. * * @since 3.0.0 */
    public function take_action() {
        if ( empty( $_POST ) ) {
            
'section'  => 'header_image',
                'removed'  => 'remove-header',
                'get_url'  => 'get_header_image',
            )
        );

    }

    /** */
    public function enqueue() {
        wp_enqueue_media();
        wp_enqueue_script( 'customize-views' );

        $this->prepare_control();

        wp_localize_script(
            'customize-views',
            '_wpCustomizeHeader',
            array(
                'data'     => array(
                    'width'         => absint( get_theme_support( 'custom-header', 'width' ) ),
                    'height'        => absint( get_theme_support( 'custom-header', 'height' ) ),
                    
$this->button_labels = wp_parse_args( $this->button_labels, $this->get_default_button_labels() );
    }

    /** * Enqueue control related scripts/styles. * * @since 3.4.0 * @since 4.2.0 Moved from WP_Customize_Upload_Control. */
    public function enqueue() {
        wp_enqueue_media();
    }

    /** * Refresh the parameters passed to the JavaScript via JSON. * * @since 3.4.0 * @since 4.2.0 Moved from WP_Customize_Upload_Control. * * @see WP_Customize_Control::to_json() */
    public function to_json() {
        

    public function enqueue_preview_scripts() {}

    /** * Loads the required scripts and styles for the widget control. * * @since 4.8.0 */
    public function enqueue_admin_scripts() {
        wp_enqueue_media();
        wp_enqueue_script( 'media-widgets' );
    }

    /** * Render form template scripts. * * @since 4.8.0 */
    public function render_control_template_scripts() {
        ?> <script type="text/html" id="tmpl-widget-media-<?php echo esc_attr( $this->id_base ); ?>-control"> <# var elementIdPrefix = 'el' + String( Math.random() ) + '_' #> <p> <label for="{{ elementIdPrefix }}title">


    /** * Sets up the enqueue for the JavaScript files. * * @since 2.1.0 */
    public function js_includes() {
        $step = $this->step();

        if ( ( 1 === $step || 3 === $step ) ) {
            wp_enqueue_media();
            wp_enqueue_script( 'custom-header' );
            if ( current_theme_supports( 'custom-header', 'header-text' ) ) {
                wp_enqueue_script( 'wp-color-picker' );
            }
        } elseif ( 2 === $step ) {
            wp_enqueue_script( 'imgareaselect' );
        }
    }

    /** * Sets up the enqueue for the CSS files. * * @since 2.7.0 */
wp_playlist_scripts( 'audio' );
        wp_playlist_scripts( 'video' );
    }

    /** * Loads the required scripts and styles for the widget control. * * @since 4.8.0 */
    public function enqueue_admin_scripts() {
        wp_enqueue_editor();
        wp_enqueue_media();
        wp_enqueue_script( 'text-widgets' );
        wp_add_inline_script( 'text-widgets', sprintf( 'wp.textWidgets.idBases.push( %s );', wp_json_encode( $this->id_base ) ) );
        wp_add_inline_script( 'text-widgets', 'wp.textWidgets.init();', 'after' );
    }

    /** * Outputs the Text widget settings form. * * @since 2.8.0 * @since 4.8.0 Form only contains hidden inputs which are synced with JS template. * @since 4.8.1 Restored original form to be displayed when in legacy mode. * * @see WP_Widget_Text::render_control_template_scripts() * @see _WP_Editors::editor() * * @param array $instance Current settings. */


$mode  = get_user_option( 'media_library_mode', get_current_user_id() ) ? get_user_option( 'media_library_mode', get_current_user_id() ) : 'grid';
$modes = array( 'grid', 'list' );

if ( isset( $_GET['mode'] ) && in_array( $_GET['mode']$modes, true ) ) {
    $mode = $_GET['mode'];
    update_user_option( get_current_user_id(), 'media_library_mode', $mode );
}

if ( 'grid' === $mode ) {
    wp_enqueue_media();
    wp_enqueue_script( 'media-grid' );
    wp_enqueue_script( 'media' );

    // Remove the error parameter added by deprecation of wp-admin/media.php.     add_filter(
        'removable_query_args',
        function() {
            return array( 'error' );
        },
        10,
        0
    );
$editor_settings['template'] = array( array( "core/$post_format) );
    }
}

if ( wp_is_block_theme() && $editor_settings['supportsTemplateMode'] ) {
    $editor_settings['defaultTemplatePartAreas'] = get_allowed_block_template_part_areas();
}

/** * Scripts */
wp_enqueue_media(
    array(
        'post' => $post->ID,
    )
);
wp_tinymce_inline_scripts();
wp_enqueue_editor();

/** * Styles */
wp_enqueue_style( 'wp-edit-post' );

$thumbnail_support = current_theme_supports( 'post-thumbnails', $post_type ) && post_type_supports( $post_type, 'thumbnail' );
if ( ! $thumbnail_support && 'attachment' === $post_type && $post->post_mime_type ) {
    if ( wp_attachment_is( 'audio', $post ) ) {
        $thumbnail_support = post_type_supports( 'attachment:audio', 'thumbnail' ) || current_theme_supports( 'post-thumbnails', 'attachment:audio' );
    } elseif ( wp_attachment_is( 'video', $post ) ) {
        $thumbnail_support = post_type_supports( 'attachment:video', 'thumbnail' ) || current_theme_supports( 'post-thumbnails', 'attachment:video' );
    }
}

if ( $thumbnail_support ) {
    add_thickbox();
    wp_enqueue_media( array( 'post' => $post->ID ) );
}

// Add the local autosave notice HTML. add_action( 'admin_footer', '_local_storage_notice' );

/* * @todo Document the $messages array(s). */
$permalink = get_permalink( $post->ID );
if ( ! $permalink ) {
    $permalink = '';
}

function media_buttons( $editor_id = 'content' ) {
    static $instance = 0;
    $instance++;

    $post = get_post();

    if ( ! $post && ! empty( $GLOBALS['post_ID'] ) ) {
        $post = $GLOBALS['post_ID'];
    }

    wp_enqueue_media( array( 'post' => $post ) );

    $img = '<span class="wp-media-buttons-icon"></span> ';

    $id_attribute = 1 === $instance ? ' id="insert-media-button"' : '';

    printf(
        '<button type="button"%s class="button insert-media add_media" data-editor="%s">%s</button>',
        $id_attribute,
        esc_attr( $editor_id ),
        $img . __( 'Add Media' )
    );

    
Home | Imprint | This part of the site doesn't use cookies.