Exemple #1
0
 /**
  * Front-end display of widget.
  * @see WP_Widget::widget()
  *
  * @param array $args     Widget arguments.
  * @param array $instance Saved values from database.
  */
 public function widget($args, $instance)
 {
     if (empty($instance['term_id'])) {
         global $gmDB;
         $term_id = $gmDB->get_terms('gmedia_album', array('status' => array('publish'), 'fields' => 'ids', 'number' => 1, 'orderby' => 'rand', 'hide_empty' => true));
         if (empty($term_id)) {
             return;
         }
         $instance['term_id'] = $term_id[0];
     }
     echo $args['before_widget'];
     if (!empty($instance['title'])) {
         echo $args['before_title'] . apply_filters('widget_title', $instance['title']) . $args['after_title'];
     }
     $atts = array('id' => (int) $instance['term_id']);
     echo gmedia_shortcode($atts);
     echo $args['after_widget'];
 }
Exemple #2
0
/**
 * @param        $atts
 * @param string $content
 *
 * @return string
 */
function gmedia_raw_shortcode($atts, $content = '')
{
    global $wp_filter, $merged_filters, $wp_current_filter;
    $wp_filter_ = $wp_filter;
    $merged_filters_ = $merged_filters;
    $wp_current_filter_ = $wp_current_filter;
    $noraw = do_shortcode(apply_filters('the_content', '[raw][/raw]'));
    $wp_filter = $wp_filter_;
    $merged_filters = $merged_filters_;
    $wp_current_filter = $wp_current_filter_;
    global $gmedia_shortcode_instance;
    // Store the unformatted content for later:
    $gmedia_shortcode_instance['shortcode_raw'][] = gmedia_shortcode($atts, $content);
    $raw_index = count($gmedia_shortcode_instance['shortcode_raw']) - 1;
    $shortcode_atts = '';
    // Put the shortcode tag back with raw index, so it gets processed again below.
    $atts['_raw'] = $raw_index;
    foreach ($atts as $key => $value) {
        $shortcode_atts .= " {$key}={$value}";
    }
    if (!$noraw) {
        //return "[raw]".gmedia_shortcode($atts, $content)."[/raw]";
        return "[raw][gmedia{$shortcode_atts}]{$content}[/gmedia][/raw]";
    } else {
        return "[gmedia{$shortcode_atts}]{$content}[/gmedia]";
    }
}
Exemple #3
0
/**
 * @param $gmedia_id
 * @param $gmedia_type
 *
 * @param null $gmedia_module
 * @param null $gmedia_module_preset
 *
 * @return string
 */
function get_the_gmedia_content($gmedia_id, $gmedia_type, $gmedia_module = null, $gmedia_module_preset = null)
{
    global $user_ID, $gmCore;
    if (!$gmedia_module) {
        global $gmedia_module;
    }
    if (!$gmedia_module_preset) {
        global $gmedia_module_preset;
    }
    $content = '';
    if (in_array($gmedia_type, array('gallery', 'album', 'tag', 'category'))) {
        $atts = array('id' => $gmedia_id, 'set_module' => $user_ID ? $gmCore->_get('set_module', $gmedia_module) : $gmedia_module, 'preset' => $user_ID ? $gmCore->_get('preset', $gmedia_module_preset) : $gmedia_module_preset, '_tax' => $gmedia_type);
        $content = gmedia_shortcode($atts);
        do_action('gmedia_enqueue_scripts');
    }
    return $content;
}
/**
 * @param $content
 *
 * @return mixed|string
 */
function gmedia_related__the_content($content)
{
    global $post, $gmDB, $gmGallery, $user_ID;
    remove_filter('the_content', 'gmedia_related__the_content', 200);
    $post_terms = get_the_tags($post->ID);
    if (empty($post_terms)) {
        return $content;
    }
    $args = array('status' => array('publish'), 'orderby' => $gmGallery->options['in_tag_orderby'], 'order' => $gmGallery->options['in_tag_order'], 'null_tags' => true);
    if ($user_ID) {
        $args['status'][] = 'private';
    }
    foreach ($post_terms as $term) {
        $args['tag_name__in'][] = $term->name;
    }
    $gmedias = $gmDB->get_gmedias($args);
    if (empty($gmedias)) {
        return $content;
    }
    unset($args['null_tags']);
    $gmedia_content = gmedia_shortcode(array('query' => $args));
    $gmedia_content = str_replace(array("\r\n", "\r", "\n"), '', $gmedia_content);
    $gmedia_content = preg_replace('/ {2,}/', ' ', $gmedia_content);
    $content .= apply_filters('before_gmedia_related__the_content', '');
    $content .= $gmedia_content;
    $content .= apply_filters('after_gmedia_related__the_content', '');
    return $content;
}
<?php

/**
 * Module Preset Preview
 */
if (!defined('ABSPATH')) {
    exit;
}
// Exit if accessed directly
if (!is_user_logged_in() || !current_user_can('gmedia_module_manage')) {
    die('-1');
}
global $wp_styles, $wp_scripts, $gmCore;
$query = $gmCore->_req('query', 'limit=20');
$module = $gmCore->_req('module');
$preset = $gmCore->_req('preset');
$atts = compact('query', 'module', 'preset');
do_action('wp_enqueue_scripts');
$wp_styles->queue = array();
$wp_scripts->queue = array();
do_action('gmedia_head');
echo gmedia_shortcode($atts);
do_action('gmedia_enqueue_scripts');
do_action('gmedia_footer');
Exemple #6
0
/**
 * @param $gmedia_id
 * @param $gmedia_type
 *
 * @param null $set
 *
 * @return string
 */
function get_the_gmedia_content($gmedia_id, $gmedia_type, $set = null)
{
    $content = '';
    if (in_array($gmedia_type, array('gallery', 'album', 'tag', 'category'))) {
        $atts = array('id' => $gmedia_id);
        $content = gmedia_shortcode($atts);
        do_action('gmedia_enqueue_scripts');
    }
    return $content;
}