Пример #1
0
        return $instance->get_title_displays();
    }
    /**
     * Returns the post types to skip for loading Envira metaboxes.
     *
     * @since 1.0.7
     *
     * @return array Array of skipped posttypes.
     */
    public function get_skipped_posttypes()
    {
        return apply_filters('envira_gallery_skipped_posttypes', array('attachment', 'revision', 'nav_menu_item', 'soliloquy', 'soliloquyv2'));
    }
    /**
     * Returns the singleton instance of the class.
     *
     * @since 1.0.0
     *
     * @return object The Envira_Gallery_Metaboxes_Lite object.
     */
    public static function get_instance()
    {
        if (!isset(self::$instance) && !self::$instance instanceof Envira_Gallery_Metaboxes_Lite) {
            self::$instance = new Envira_Gallery_Metaboxes_Lite();
        }
        return self::$instance;
    }
}
// Load the metabox class.
$envira_gallery_metaboxes_lite = Envira_Gallery_Metaboxes_Lite::get_instance();
Пример #2
0
/**
 * Refreshes the DOM view for a gallery.
 *
 * @since 1.0.0
 */
function envira_gallery_lite_ajax_refresh()
{
    // Run a security check first.
    check_ajax_referer('envira-gallery-refresh', 'nonce');
    // Prepare variables.
    $post_id = absint($_POST['post_id']);
    $gallery = '';
    // Grab all gallery data.
    $gallery_data = get_post_meta($post_id, '_eg_gallery_data', true);
    // If there are no gallery items, don't do anything.
    if (empty($gallery_data) || empty($gallery_data['gallery'])) {
        echo json_encode(array('error' => true));
        die;
    }
    // Loop through the data and build out the gallery view.
    foreach ((array) $gallery_data['gallery'] as $id => $data) {
        $gallery .= Envira_Gallery_Metaboxes_Lite::get_instance()->get_gallery_item($id, $data, $post_id);
    }
    echo json_encode(array('success' => $gallery));
    die;
}