public static function get_name($args)
 {
     $name = isset($args['name']) ? trim($args['name']) : '';
     if (empty($name)) {
         return $name;
     }
     $sbmb = substr($name, 0, 4);
     if ('sbmb' != $sbmb) {
         $name = sb_build_meta_name($name);
     }
     return $name;
 }
示例#2
0
    public static function media_upload_group($args = array())
    {
        $name = isset($args['name']) ? trim($args['name']) : '';
        if (empty($name)) {
            return;
        }
        $name = sb_build_meta_name($name);
        $value = isset($args['value']) ? trim($args['value']) : '';
        $field_class = isset($args['field_class']) ? trim($args['field_class']) : '';
        $field_class = SB_PHP::add_string_with_space_before($field_class, 'image-url image-upload-url');
        $upload_button_class = isset($args['upload_button_class']) ? trim($args['upload_button_class']) : '';
        $remove_button_class = isset($args['remove_button_class']) ? trim($args['remove_button_class']) : '';
        $upload_button_class = SB_PHP::add_string_with_space_before($upload_button_class, 'sb-button button sb-insert-media sb-add_media');
        $remove_button_class = SB_PHP::add_string_with_space_before($remove_button_class, 'sb-button button sb-remove-media sb-remove-image');
        ?>
        <input type="url" name="<?php 
        echo esc_attr($name);
        ?>
" value="<?php 
        echo $value;
        ?>
" autocomplete="off" class="<?php 
        echo $field_class;
        ?>
">
        <a href="javascript:;" class="<?php 
        echo $upload_button_class;
        ?>
" title="<?php 
        _e('Insert image', 'sb-core');
        ?>
"><?php 
        _e('Upload', 'sb-core');
        ?>
</a>
        <a href="javascript:;" class="<?php 
        echo $remove_button_class;
        ?>
" title="<?php 
        _e('Remove image', 'sb-core');
        ?>
"><?php 
        _e('Remove', 'sb-core');
        ?>
</a>
        <?php 
    }
示例#3
0
 public static function media_upload_group($args = array())
 {
     $name = isset($args['name']) ? trim($args['name']) : '';
     if (empty($name)) {
         return;
     }
     $name = sb_build_meta_name($name);
     $value = isset($args['value']) ? trim($args['value']) : '';
     $field_class = isset($args['field_class']) ? trim($args['field_class']) : '';
     $field_class = SB_PHP::add_string_with_space_before($field_class, 'image-url image-upload-url');
     $upload_button_class = isset($args['upload_button_class']) ? trim($args['upload_button_class']) : '';
     $remove_button_class = isset($args['remove_button_class']) ? trim($args['remove_button_class']) : '';
     $upload_button_class = SB_PHP::add_string_with_space_before($upload_button_class, 'sb-button button sb-insert-media sb-add_media');
     $remove_button_class = SB_PHP::add_string_with_space_before($remove_button_class, 'sb-button button sb-remove-media sb-remove-image');
     if (!isset($args['before'])) {
         $args['before'] = '';
     }
     self::media_upload_no_preview($args);
 }
示例#4
0
 public static function update_sb_meta($post_id, $meta_key, $meta_value)
 {
     $meta_key = sb_build_meta_name($meta_key);
     self::update_meta($post_id, $meta_key, $meta_value);
 }
    public static function image_upload($args = array())
    {
        $name = isset($args['name']) ? trim($args['name']) : '';
        if (empty($name)) {
            return;
        }
        $name = sb_build_meta_name($name);
        $container_class = isset($args['container_class']) ? trim($args['container_class']) : '';
        $container_class = SB_PHP::add_string_with_space_before($container_class, 'sb-media-upload');
        $preview = isset($args['preview']) ? (bool) $args['preview'] : false;
        $label = isset($args['label']) ? $args['label'] : '';
        $container_class = SB_PHP::add_string_with_space_before($container_class, 'sb-post-meta-row');
        $tag = 'p';
        if ($preview) {
            $tag = 'div';
        }
        $value = isset($args['value']) ? $args['value'] : '';
        $image_preview_class = 'image-preview';
        if (!empty($value)) {
            $image_preview_class = SB_PHP::add_string_with_space_before($image_preview_class, 'has-image');
        }
        ?>
        <<?php 
        echo $tag;
        ?>
 class="<?php 
        echo $container_class;
        ?>
">
            <label for="<?php 
        echo esc_attr($name);
        ?>
" class="display-block"><?php 
        echo $label;
        ?>
:</label>
            <?php 
        SB_Field::media_upload_group($args);
        ?>
            <?php 
        if ($preview) {
            ?>
                <div class="<?php 
            echo $image_preview_class;
            ?>
">
                    <?php 
            if (!empty($value)) {
                ?>
                        <img src="<?php 
                echo $value;
                ?>
" alt="">
                    <?php 
            }
            ?>
                </div>
            <?php 
        }
        ?>
        </<?php 
        echo $tag;
        ?>
>
    <?php 
    }