Exemplo n.º 1
0
 public function render()
 {
     $html = '';
     $html .= '<div' . $this->static_ticker_width() . ' id="' . $this->ticker_id . '" ' . mtphr_dnt_ticker_class($this->post_id, $this->classes, $this->meta) . '>';
     $html .= '<div class="mtphr-dnt-wrapper mtphr-dnt-clearfix">';
     // Open the ticker container
     do_action('mtphr_dnt_before', $this->post_id, $this->meta);
     echo '<div class="mtphr-dnt-tick-container"' . $container_style . '>';
     do_action('mtphr_dnt_contents_before', $this->post_id, $this->meta);
     echo '<div class="mtphr-dnt-tick-contents">';
     do_action('mtphr_dnt_top', $this->post_id, $this->meta);
     // Print out the ticks
     if (is_array($this->ticks)) {
         $html .= ob_get_clean();
         foreach ($this->ticks as $i => $tick_obj) {
             ob_start();
             mtphr_dnt_tick_open($tick_obj, $i, $this->post_id, $this->meta, $this->total_ticks);
             $tick = is_array($tick_obj) && isset($tick_obj['tick']) ? $tick_obj['tick'] : $tick_obj;
             echo $tick;
             mtphr_dnt_tick_close($tick_obj, $i, $this->post_id, $this->meta, $this->total_ticks);
             $html .= ob_get_clean();
         }
         ob_start();
     }
     // Close the ticker container
     do_action('mtphr_dnt_bottom', $this->post_id, $this->meta);
     echo '</div>';
     do_action('mtphr_dnt_contents_after', $this->post_id, $this->meta, $this->total_ticks);
     echo '</div>';
     do_action('mtphr_dnt_after', $this->post_id, $this->meta, $this->total_ticks);
     echo '</div>';
     echo '</div>';
 }
Exemplo n.º 2
0
function render_mtphr_dnt_rotate_ticker($id = '', $class = '', $meta_data = false)
{
    $html = '';
    // Save the original $wp_query
    global $mtphr_dnt_ticker_types, $mtphr_dnt_meta_data, $mtphr_dnt_rotate_ticks;
    // Extract the metadata array into variables
    extract($meta_data);
    // Add to the global ticker types
    $mtphr_dnt_ticker_types[$_mtphr_dnt_type] = $_mtphr_dnt_type;
    // Get the ticks to display
    if ($_mtphr_dnt_type == 'mixed') {
        $dnt_ticks = mtphr_dnt_mixed_ticks($id, $meta_data);
    } else {
        $dnt_ticks = apply_filters('mtphr_dnt_tick_array', array(), $id, $meta_data);
    }
    // Transform the tick array
    $dnt_ticks = apply_filters('mtphr_dnt_tick_array_transform', $dnt_ticks, $id, $meta_data);
    // Randomize the ticks
    if (isset($_mtphr_dnt_shuffle) && $_mtphr_dnt_shuffle) {
        shuffle($dnt_ticks);
    }
    // Add the post amount of ticks to the metadata
    $total_ticks = count($dnt_ticks);
    // Add the post id & total ticks to the metadata
    $meta_data['_mtphr_dnt_id'] = $id;
    $meta_data['_mtphr_dnt_total_ticks'] = $total_ticks;
    // Save the metadata in a global variable
    $mtphr_dnt_meta_data = $meta_data;
    ob_start();
    // Add a unique id
    $tick_id = 'mtphr-dnt-' . $id;
    if (isset($_mtphr_dnt_unique_id) && $_mtphr_dnt_unique_id != '') {
        $tick_id = 'mtphr-dnt-' . $id . '-' . sanitize_html_class($_mtphr_dnt_unique_id);
    }
    // Add to the global carousel ticks
    $mtphr_dnt_rotate_ticks[$tick_id] = array();
    // Check for a set width
    $ticker_width = '';
    if (isset($_mtphr_dnt_ticker_width) && $_mtphr_dnt_ticker_width != 0) {
        $ticker_width = ' style="width:' . intval($_mtphr_dnt_ticker_width) . 'px"';
    }
    echo '<div' . $ticker_width . ' id="' . $tick_id . '" ' . mtphr_dnt_ticker_class($id, $class, $meta_data) . '>';
    echo '<div class="mtphr-dnt-wrapper mtphr-dnt-clearfix">';
    // Create and save element styles
    $padding = intval($_mtphr_dnt_rotate_padding) != 0 ? 'padding-top:' . intval($_mtphr_dnt_rotate_padding) . 'px;padding-bottom:' . intval($_mtphr_dnt_rotate_padding) . 'px;' : '';
    $margin = intval($_mtphr_dnt_rotate_margin) != 0 ? 'margin-top:' . intval($_mtphr_dnt_rotate_margin) . 'px;margin-bottom:' . intval($_mtphr_dnt_rotate_margin) . 'px;' : '';
    // Filter the variables
    $padding = apply_filters('mtphr_dnt_tick_container_padding', $padding);
    $margin = apply_filters('mtphr_dnt_tick_container_margin', $margin);
    // Create the container style
    $container_style = $padding != '' || $margin != '' ? ' style="' . $padding . $margin . '"' : '';
    // Open the ticker container
    do_action('mtphr_dnt_before', $id, $meta_data);
    echo '<div class="mtphr-dnt-tick-container"' . $container_style . '>';
    do_action('mtphr_dnt_contents_before', $id, $meta_data);
    echo '<div class="mtphr-dnt-tick-contents">';
    do_action('mtphr_dnt_top', $id, $meta_data);
    // Print out the ticks
    if (is_array($dnt_ticks)) {
        $html .= ob_get_clean();
        foreach ($dnt_ticks as $i => $tick_obj) {
            ob_start();
            mtphr_dnt_tick_open($tick_obj, $i, $id, $meta_data, $total_ticks);
            $tick = is_array($tick_obj) && isset($tick_obj['tick']) ? $tick_obj['tick'] : $tick_obj;
            echo $tick;
            mtphr_dnt_tick_close($tick_obj, $i, $id, $meta_data, $total_ticks);
            $html .= $mtphr_dnt_rotate_ticks[$tick_id][] = ob_get_clean();
        }
        ob_start();
    }
    // Close the ticker container
    do_action('mtphr_dnt_bottom', $id, $meta_data);
    echo '</div>';
    do_action('mtphr_dnt_contents_after', $id, $meta_data, $total_ticks);
    echo '</div>';
    do_action('mtphr_dnt_after', $id, $meta_data, $total_ticks);
    echo '</div>';
    echo '</div>';
    $html .= ob_get_clean();
    return $html;
}