/** * Prepares sites to use the plugin during single or network-wide activation * * @since 2.0 * * @param bool $network_wide */ public function activate($network_wide) { self::update_slug(); delete_option('wpmoly_has_deprecated_meta'); if (!wpmoly_has_deprecated_meta()) { return false; } $deprecated = self::get_deprecated_movies(); if (false !== $deprecated) { $deprecated = count($deprecated); } else { $deprecated = '0'; } add_option('wpmoly_has_deprecated_meta', $deprecated, null, 'no'); }
<?php /** * WPMovieLibrary Config Admin menu definition * * @package WPMovieLibrary * @author Charlie MERLAND <*****@*****.**> * @license GPL-3.0 * @link http://www.caercam.org/ * @copyright 2014 Charlie MERLAND */ // If this file is called directly, abort. if (!defined('WPINC')) { wp_die(); } $wpmoly_admin_bar_menu = array('menu' => array('id' => 'wpmovielibrary', 'title' => '<span class="wpmolicon icon-wpmoly"></span> ' . __('Movie Library', 'wpmovielibrary'), 'href' => admin_url('admin.php?page=wpmovielibrary')), 'submenu' => array(array('parent' => 'wpmovielibrary', 'id' => 'wpmoly-library', 'title' => __('Your movie library', 'wpmovielibrary'), 'href' => admin_url('admin.php?page=wpmovielibrary')), array('parent' => 'wpmoly-movies', 'id' => 'wpmoly-all-movies', 'title' => __('View all movies', 'wpmovielibrary'), 'href' => admin_url('edit.php?post_type=movie')), array('parent' => 'wpmoly-movies', 'id' => 'wpmoly-new-movie', 'title' => __('Add new movie', 'wpmovielibrary'), 'href' => admin_url('post-new.php?post_type=movie')), array('parent' => 'wpmoly-movies', 'id' => 'wpmoly-import-movies', 'title' => __('Import movies', 'wpmovielibrary'), 'href' => admin_url('admin.php?page=wpmovielibrary-import')), array('parent' => 'wpmoly-utils', 'id' => 'wpmoly-settings', 'title' => __('Library Settings', 'wpmovielibrary'), 'href' => admin_url('admin.php?page=wpmovielibrary-settings')), array('parent' => 'wpmoly-utils', 'id' => 'wpmoly-about', 'title' => __('About WPMovieLibrary', 'wpmovielibrary'), 'href' => admin_url('index.php?page=wpmovielibrary-about')), array('parent' => 'wpmoly-utils', 'id' => 'wpmoly-movie-update', 'title' => __('Update movies', 'wpmovielibrary'), 'href' => admin_url('admin.php?page=wpmovielibrary-update-movies'), 'meta' => array('class' => 'active'), 'condition' => wpmoly_has_deprecated_meta())), 'group' => array(array('parent' => 'wpmovielibrary', 'id' => 'wpmoly-movies', 'meta' => array('class' => 'ab-sub-secondary')), array('parent' => 'wpmovielibrary', 'id' => 'wpmoly-utils', 'meta' => array('class' => 'ab-sub-third'))));
/** * Return various Movie's Post Meta. Possible meta: status, media, rating * and data. * * @since 1.0 * * @param int Movie Post ID * @param string Meta type to return: data, status, media or rating * * @return array|string WPMOLY Movie Meta if available, empty string else. */ public static function get_movie_meta($post_id = null, $meta = null) { if (is_null($post_id)) { $post_id = get_the_ID(); } if (!($post = get_post($post_id) || 'movie' != get_post_type($post_id))) { return false; } if (is_admin() && 'data' == $meta && wpmoly_has_deprecated_meta($post_id) && wpmoly_o('legacy-mode')) { WPMOLY_Legacy::update_movie($post_id); } if ('data' == $meta || 'meta' == $meta) { $_meta = WPMOLY_Settings::get_supported_movie_meta(); $value = array(); $value['tmdb_id'] = get_post_meta($post_id, "_wpmoly_movie_tmdb_id", true); $value['poster'] = get_post_meta($post_id, "_wpmoly_movie_poster", true); foreach (array_keys($_meta) as $slug) { $value[$slug] = get_post_meta($post_id, "_wpmoly_movie_{$slug}", true); } return $value; } else { if ('details' == $meta) { $details = WPMOLY_Settings::get_supported_movie_details(); $value = array(); foreach (array_keys($details) as $slug) { $value[$slug] = get_post_meta($post_id, "_wpmoly_movie_{$slug}", true); } return $value; } } $value = get_post_meta($post_id, "_wpmoly_movie_{$meta}", true); if ('rating' == $meta) { $value = number_format(floatval($value), 1); } return $value; }