php [壮举图片2] Agregar un param a feature image(en este caso transparencia #wordpress #php

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了php [壮举图片2] Agregar un param a feature image(en este caso transparencia #wordpress #php相关的知识,希望对你有一定的参考价值。

<?php
// add combo to Featured image 
function add_featured_image_display_settings( $content, $post_id ) {
	$field_id    = 'qbf_opacity';
	$field_value = esc_attr( get_post_meta( $post_id, $field_id, true ) );
    $field_value = (empty($field_value))? '1.0' : $field_value;
	$field_text  = 'Opacity';

    $options_list = '';
    for($i = 1; $i <= 10; $i++) {
        $opacity = number_format(round($i / 10, 1),1);
        $selected = ($opacity == $field_value)? ' selected ' : '';
        $options_list .= '<option value="'. $opacity .'"'. $selected .'>'. $opacity .'</option>';
    }

    $field_label = 
        '<p><label for="'. $field_id .'">'. $field_text . 
        '<select name="'. $field_id .'" id="'. $field_id .'">'. 
            $options_list .
        '</select>'. 
        '</label></p>';

	return $content .= $field_label;
}
add_filter( 'admin_post_thumbnail_html', 'add_featured_image_display_settings', 10, 2 );


// save custom combo in Featured image
function save_featured_image_display_settings( $post_ID, $post, $update ) {
	$field_id    = 'qbf_opacity';
    if(array_key_exists($field_id, $_REQUEST)) {
        $field_value = $_REQUEST[ $field_id ];    
    } else {
        $field_value = '1.0';
    }
	

	update_post_meta( $post_ID, $field_id, $field_value );
}
add_action( 'save_post', 'save_featured_image_display_settings', 10, 3 );

以上是关于php [壮举图片2] Agregar un param a feature image(en este caso transparencia #wordpress #php的主要内容,如果未能解决你的问题,请参考以下文章

javascript agregar javascript en un documento add js / agregar JS en pagina apex

javascript agregar javascript en un documento

PHP Php - Agregar href en textos

php Agregar项目菜单前端

php agregar自定义菜单

php Agregar columna en posttype