Plugin Directory

Changeset 2712012


Ignore:
Timestamp:
04/20/2022 08:28:32 AM (4 years ago)
Author:
kvsteam
Message:

1.0.8

  • Added support for post status (draft, published, pending).
  • Added support for up to 3 custom fields to be populated with KVS data.
Location:
kernel-video-sharing/trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • kernel-video-sharing/trunk/README.txt

    r2668122 r2712012  
    44Tags: video, player, tube, videoplayer
    55Requires at least: 3.0.1
    6 Tested up to: 5.9.0
    7 Stable tag: 1.0.7
     6Tested up to: 5.9.3
     7Stable tag: 1.0.8
    88Requires PHP: 7.1
    99License: GPLv2 or later
     
    5757= 1.0.7 =
    5858* Consmetical changes
     59
     60= 1.0.8 =
     61* Added support for post status (draft, published, pending).
     62* Added support for up to 3 custom fields to be populated with KVS data.
  • kernel-video-sharing/trunk/admin/class-kvs-admin.php

    r2667866 r2712012  
    510510        $taxonomy_model    = get_option( 'kvs_taxonomy_model' );
    511511        $taxonomy_source   = get_option( 'kvs_taxonomy_source' );
     512
     513        $custom_fields = [];
     514        for ($i = 1; $i <= 3; $i++) {
     515            if (!empty(get_option( "kvs_custom{$i}_name" )) && !empty(get_option( "kvs_custom{$i}_value" ))) {
     516                $custom_fields[get_option( "kvs_custom{$i}_name" )] = get_option( "kvs_custom{$i}_value" );
     517            }
     518        }
    512519       
    513520        $kernel_video_sharing->logger->log(
     
    621628                        ),
    622629                    );
    623                    
     630
    624631                    $replacements = array(
    625632                        '{%id%}'             => $row['id'],
     
    636643                    $contentTemplate = get_option( 'kvs_post_body_template' ) ?: '{%description%}';
    637644                    $video['post_content'] = strtr( $contentTemplate, $replacements);
     645
     646                    foreach ($custom_fields as $custom_field_name => $custom_field_value) {
     647                        $video['meta_input'][$custom_field_name] = strtr($custom_field_value, $replacements);
     648                    }
    638649                   
    639650                    if( !empty( $row['screenshot_main'] ) &&
     
    667678                        }
    668679                    } else {
    669                         $video['post_status'] = 'publish'; // ToDo: Move that initial state setting to options
     680                        $video['post_status'] = get_option( 'kvs_post_status' ) == 'draft' ? 'draft' : (get_option( 'kvs_post_status' ) == 'pending' ? 'pending' : 'publish');
    670681                        $video['post_author'] = 1;  // ToDo: Try to find corresponding WP user by $row['user']
    671682                        $post_id = wp_insert_post( $video, $wp_error = true );
  • kernel-video-sharing/trunk/admin/css/kvs-admin.css

    r2667866 r2712012  
    8080}
    8181.hint code {
    82     cursor: pointer;
    8382    display: inline-block;
    8483}
  • kernel-video-sharing/trunk/admin/partials/settings/post.php

    r2667866 r2712012  
    6262            </label>
    6363            <p class="description">Choose which post type you want KVS videos to be imported to</p>
     64        </td>
     65        </tr>
     66
     67        <tr valign="top">
     68        <th scope="row"><?php _e( 'Post status', 'kvs' ); ?></th>
     69        <td>
     70            <select name="kvs_post_status">
     71                <option value="published" <?php if( get_option( 'kvs_post_status' ) == 'published' ){echo ' selected';} ?>><?php _e( 'Published', 'kvs' ); ?></option>
     72                <option value="pending" <?php if( get_option( 'kvs_post_status' ) == 'pending' ){echo ' selected';} ?>><?php _e( 'Pending Review', 'kvs' ); ?></option>
     73                <option value="draft" <?php if( get_option( 'kvs_post_status' ) == 'draft' ){echo ' selected';} ?>><?php _e( 'Draft', 'kvs' ); ?></option>
     74            </select>
     75            <p class="description">Status of the created posts</p>
    6476        </td>
    6577        </tr>
     
    182194        </tr>
    183195    </table>
     196
     197    <h3>Custom fields</h3>
     198    <table class="form-table">
     199        <tr valign="top">
     200        <th scope="row"><?php _e( 'Custom 1', 'kvs' ); ?></th>
     201        <td>
     202            <input type="text" name="kvs_custom1_name" value="<?php echo esc_attr( get_option( 'kvs_custom1_name' )); ?>" />
     203            =
     204            <input type="text" name="kvs_custom1_value" value="<?php echo esc_attr( get_option( 'kvs_custom1_value' )); ?>" />
     205            <p class="description">Specify custom field name and value (see <b>Template elements</b> above)</p>
     206        </td>
     207        </tr>
     208        <tr valign="top">
     209        <th scope="row"><?php _e( 'Custom 2', 'kvs' ); ?></th>
     210        <td>
     211            <input type="text" name="kvs_custom2_name" value="<?php echo esc_attr( get_option( 'kvs_custom2_name' )); ?>" />
     212            =
     213            <input type="text" name="kvs_custom2_value" value="<?php echo esc_attr( get_option( 'kvs_custom2_value' )); ?>" />
     214            <p class="description">Specify custom field name and value (see <b>Template elements</b> above)</p>
     215        </td>
     216        </tr>
     217        <tr valign="top">
     218        <th scope="row"><?php _e( 'Custom 3', 'kvs' ); ?></th>
     219        <td>
     220            <input type="text" name="kvs_custom3_name" value="<?php echo esc_attr( get_option( 'kvs_custom3_name' )); ?>" />
     221            =
     222            <input type="text" name="kvs_custom3_value" value="<?php echo esc_attr( get_option( 'kvs_custom3_value' )); ?>" />
     223            <p class="description">Specify custom field name and value (see <b>Template elements</b> above)</p>
     224        </td>
     225        </tr>
     226    </table>
    184227    <?php submit_button( __( 'Save Changes', 'kvs' ) ); ?>
    185228</form>
    186229</div>
    187 <script>
    188     jQuery(document).ready(function() {
    189         jQuery('code').on('click', function() {
    190             var templatetext = jQuery("#kvs_post_body_template");
    191             var position = templatetext.getCursorPosition();
    192             templatetext.val(
    193                 templatetext.val().substr(0, position) +
    194                 this.innerText +
    195                 templatetext.val().substr(position)
    196             );
    197         });
    198     });
    199     (function ($, undefined) {
    200         $.fn.getCursorPosition = function () {
    201             var el = $(this).get(0);
    202             var pos = 0;
    203             if ('selectionStart' in el) {
    204                 pos = el.selectionStart;
    205             } else if ('selection' in document) {
    206                 el.focus();
    207                 var Sel = document.selection.createRange();
    208                 var SelLength = document.selection.createRange().text.length;
    209                 Sel.moveStart('character', -el.value.length);
    210                 pos = Sel.text.length - SelLength;
    211             }
    212             return pos;
    213         }
    214     })(jQuery);
    215 </script>
  • kernel-video-sharing/trunk/includes/class-kvs.php

    r2667866 r2712012  
    314314       
    315315        register_setting( 'kvs-settings-group-post', 'kvs_post_type' );
     316        register_setting( 'kvs-settings-group-post', 'kvs_post_status' );
    316317        register_setting( 'kvs-settings-group-post', 'kvs_post_import_featured_image' );
    317318        register_setting( 'kvs-settings-group-post', 'kvs_post_body_template' );
     
    320321        register_setting( 'kvs-settings-group-post', 'kvs_taxonomy_model' );
    321322        register_setting( 'kvs-settings-group-post', 'kvs_taxonomy_source' );
     323        register_setting( 'kvs-settings-group-post', 'kvs_custom1_name' );
     324        register_setting( 'kvs-settings-group-post', 'kvs_custom1_value' );
     325        register_setting( 'kvs-settings-group-post', 'kvs_custom2_name' );
     326        register_setting( 'kvs-settings-group-post', 'kvs_custom2_value' );
     327        register_setting( 'kvs-settings-group-post', 'kvs_custom3_name' );
     328        register_setting( 'kvs-settings-group-post', 'kvs_custom3_value' );
    322329
    323330        register_setting( 'kvs-settings-group-advanced', 'kvs_feed_last_id' );
  • kernel-video-sharing/trunk/kvs.php

    r2668122 r2712012  
    1212 * Plugin URI:        https://www.kernel-video-sharing.com/en/wordpress/
    1313 * Description:       Kernel Video Sharing plugin for WordPress. Provides integration with KVS video content manager and automates video import from KVS into your Wordpress projects.
    14  * Version:           1.0.7
     14 * Version:           1.0.8
    1515 * Requires at least: 5.0
    1616 * Requires PHP:      5.6
     
    2929
    3030define( 'KVS_WEBSITE', 'https://www.kernel-video-sharing.com/' );
    31 define( 'KVS_VERSION', '1.0.7' );
     31define( 'KVS_VERSION', '1.0.8' );
    3232define( 'KVS_PREFIX', 'kvs' );
    3333define( 'KVS_DIRPATH', plugin_dir_path( __FILE__ ) );
Note: See TracChangeset for help on using the changeset viewer.