Example #1
0
/**
 * Enqueue the featured media javascript
 *
 * @global $post
 * @global LARGO_DEBUG
 * @param array $hook The page that this function is being run on.
 */
function largo_enqueue_featured_media_js($hook)
{
    if (!in_array($hook, array('edit.php', 'post-new.php', 'post.php'))) {
        return;
    }
    global $post;
    $featured_image_display = get_post_meta($post->ID, 'featured-image-display', true);
    $suffix = LARGO_DEBUG ? '' : '.min';
    wp_enqueue_script('largo_featured_media', get_template_directory_uri() . '/js/featured-media' . $suffix . '.js', array('media-models', 'media-views'), false, 1);
    wp_localize_script('largo_featured_media', 'LFM', array('options' => largo_default_featured_media_types(), 'featured_image_display' => !empty($featured_image_display), 'has_featured_media' => (bool) largo_has_featured_media($post->ID)));
}
 function test_largo_default_featured_media_types()
 {
     $media_types = largo_default_featured_media_types();
     $this->assertEquals(count($media_types), count($this->media_types));
 }
Example #3
0
/**
 * Enqueue the featured media javascript
 *
 * @global $post
 * @global LARGO_DEBUG
 * @param array $hook The page that this function is being run on.
 */
function largo_enqueue_featured_media_js($hook)
{
    if (!in_array($hook, array('edit.php', 'edit-tags.php', 'post-new.php', 'post.php'))) {
        return;
    }
    global $post, $wp_query;
    if (in_array($hook, array('edit-tags.php')) && isset($_GET['action'])) {
        $post = get_post(largo_get_term_meta_post($_GET['taxonomy'], $_GET['tag_ID']));
    }
    $featured_image_display = get_post_meta($post->ID, 'featured-image-display', true);
    $suffix = LARGO_DEBUG ? '' : '.min';
    wp_enqueue_script('largo_featured_media', get_template_directory_uri() . '/js/featured-media' . $suffix . '.js', array('media-models', 'media-views'), false, 1);
    wp_enqueue_style('largo_featured_media', get_template_directory_uri() . '/css/featured-media' . $suffix . '.css');
    wp_localize_script('largo_featured_media', 'LFM', array('options' => largo_default_featured_media_types(), 'featured_image_display' => !empty($featured_image_display), 'has_featured_media' => (bool) largo_has_featured_media($post->ID)));
}