/** * Checks if the plugin has been updated and performs any necessary updates. */ function theplatform_check_plugin_update() { $oldVersion = theplatform_plugin_version_changed(); if (FALSE === $oldVersion) { return; } $newVersion = TP_PLUGIN_VERSION(); // On any version, update defaults that didn't previously exist and update the plugin version $newPreferences = array_merge(TP_PREFERENCES_OPTIONS_DEFAULTS(), get_option(TP_PREFERENCES_OPTIONS_KEY, array())); $newPreferences['plugin_version'] = TP_PLUGIN_VERSION; update_option(TP_PREFERENCES_OPTIONS_KEY, $newPreferences); update_option(TP_ACCOUNT_OPTIONS_KEY, array_merge(TP_ACCOUNT_OPTIONS_DEFAULTS(), get_option(TP_ACCOUNT_OPTIONS_KEY, array()))); update_option(TP_UPLOAD_OPTIONS_KEY, array_merge(TP_UPLOAD_FIELDS_DEFAULTS(), get_option(TP_UPLOAD_OPTIONS_KEY, array()))); // Set the default embed hook and media embed types (1.2.2 ~ 1.3.2) if ($oldVersion['major'] == '1' && $oldVersion['minor'] == '2' && $oldVersion['patch'] == '2' || $oldVersion['major'] == '1' && $oldVersion['minor'] == '3' && $oldVersion['patch'] < '3') { if (defined('WPCOM_IS_VIP_ENV')) { $newPreferences['embed_hook'] = 'tinymce'; // VIP Only } $newPreferences['media_embed_type'] = 'release'; update_option(TP_PREFERENCES_OPTIONS_KEY, $newPreferences); } // We had a messy update with 1.2.2/1.3.0, let's clean up if ($oldVersion['major'] == '1' && $oldVersion['minor'] == '2' && $oldVersion['patch'] == '2' || $oldVersion['major'] == '1' && $oldVersion['minor'] == '3' && $oldVersion['patch'] == '0') { $basicMetadataFields = get_option(TP_UPLOAD_OPTIONS_KEY, array()); $customMetadataFields = get_option(TP_METADATA_OPTIONS_KEY, array()); update_option(TP_UPLOAD_OPTIONS_KEY, array_diff_assoc($basicMetadataFields, $customMetadataFields)); } // Move account settings from preferences (1.2.0) if ($oldVersion['major'] == '1' && $oldVersion['minor'] < '2' && ($newVersion['major'] > '1' || $newVersion['major'] >= '1' && $newVersion['minor'] >= '2')) { $preferences = get_option(TP_PREFERENCES_OPTIONS_KEY, array()); if (array_key_exists('mpx_account_id', $preferences)) { $accountSettings = TP_ACCOUNT_OPTIONS_DEFAULTS(); foreach ($preferences as $key => $value) { if (array_key_exists($key, $accountSettings)) { $accountSettings[$key] = $preferences[$key]; } } update_option(TP_ACCOUNT_OPTIONS_KEY, $accountSettings); } } }
function register_basic_metadata_options() { if (!$this->account_is_verified || !$this->region_is_verified) { return; } $this->plugin_settings_tabs[TP_UPLOAD_OPTIONS_KEY] = 'Basic Metadata'; $upload_fields = TP_UPLOAD_FIELDS_DEFAULTS(); add_settings_section('section_upload_options', 'Basic Metadata Settings', array($this, 'section_basic_metadata_desc'), TP_UPLOAD_OPTIONS_KEY); foreach ($upload_fields as $field => $value) { if (!array_key_exists($field, $this->upload_options)) { $this->upload_options[$field] = 'write'; } $field_title = strstr($field, '$') !== false ? substr(strstr($field, '$'), 1) : $field; add_settings_field($field, ucfirst($field_title), array($this, 'field_basic_metadata_option'), TP_UPLOAD_OPTIONS_KEY, 'section_upload_options', array('field' => $field)); } }
<?php if (!defined('ABSPATH')) { exit; } $tp_viewer_cap = apply_filters(TP_VIEWER_CAP, TP_VIEWER_DEFAULT_CAP); if (!current_user_can($tp_viewer_cap)) { wp_die('<p>You do not have sufficient permissions to browse MPX Media</p>'); } if (!class_exists('ThePlatform_API')) { require_once dirname(__FILE__) . '/thePlatform-API.php'; } $tp_api = new ThePlatform_API(); $metadata = $tp_api->get_metadata_fields(); define('TP_MEDIA_BROWSER', true); $metadata_options = get_option(TP_METADATA_OPTIONS_KEY, array()); $upload_options = get_option(TP_UPLOAD_OPTIONS_KEY, TP_UPLOAD_FIELDS_DEFAULTS()); $preferences = get_option(TP_PREFERENCES_OPTIONS_KEY); $account = get_option(TP_ACCOUNT_OPTIONS_KEY); if (strcmp($account['mpx_account_id'], "") == 0) { wp_die('MPX Account ID is not set, please configure the plugin before attempting to manage media'); } //Embed only stuff $players = $tp_api->get_players(); $IS_EMBED = isset($_GET['embed']) ? true : false; function writePlayers($players, $preferences) { $html = '<p class="navbar-text sort-bar-text">Player:</p><form class="navbar-form navbar-left sort-bar-nav" role="sort"><select id="selectpick-player" class="form-control">'; foreach ($players as $player) { $html .= '<option value="' . esc_attr($player['pid']) . '"' . selected($player['pid'], $preferences['default_player_pid'], false) . '>' . esc_html($player['title']) . '</option>'; } $html .= '</select></form>';