Plugin Directory

Changeset 2007718


Ignore:
Timestamp:
01/07/2019 12:30:53 PM (7 years ago)
Author:
albreis
Message:

Changed default 'show_date' and 'show_author' config. Add query optimization args. Bugs fixes.

Location:
albnet-shortcodes/trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • albnet-shortcodes/trunk/README.txt

    r2007581 r2007718  
    147147
    1481481.1.5 Add fields 'order' and 'orderby' to set posts ordering
     149
     1501.2.5 Changed default 'show_date' and 'show_author' config. Add query optimization args. Bugs fixes.
  • albnet-shortcodes/trunk/albnet-shortcodes.php

    r2007581 r2007718  
    1212 * Plugin URI: https://shortcodes.albreis.com.br
    1313 * Description: A lot of shortcodes to show posts
    14  * Version: 1.1.5
     14 * Version: 1.2.5
    1515 * Author: Albreis Network <[email protected]>
    1616 * Author URI: https://albreis.com.br
     
    2121 */
    2222
     23defined('IS_MOBILE') or define('IS_MOBILE', wp_is_mobile());
     24
    2325/**
    2426 * Load settings page
     
    8183
    8284        // Section title
    83         'title' => 'Vídeos',
     85        'title' => '',
    8486
    8587        // Post type
     
    9395
    9496        // Posts ordering
    95         'order' => 'ASC',
     97        'order' => 'DESC',
    9698
    9799        // Field to ordering
     
    114116
    115117        //Show only posts with featured images?
    116         'only_with_thumb' => false,
     118        'only_with_thumb' => true,
    117119
    118120        // Show post thumbnail?
     
    135137
    136138        // Show post times ago?
    137         'show_times_ago' => false,
     139        'show_times_ago' => true,
    138140
    139141        // Show post category?
     
    142144        // Show post comments?
    143145        'show_comments' => false,
     146
     147        // Show views?
     148        'show_views' => true,
    144149
    145150        // Icon to show before title
     
    152157        'item_class' => ''
    153158    ], $atts );
     159
    154160   
    155161    include 'shortcode-' . $a['layout'] . '.php';
     
    157163}
    158164
    159 function albnet_get_args($a) {
     165function albnet_get_args($conf) {
     166
    160167   
    161168    /**
    162169     * Post type
    163170     */
    164     $args['post_type'] = $a['post_type'];
     171    $albnet_args['post_type'] = $conf['post_type'];
    165172
    166173    /**
    167174     * Posts per page
    168175     */
    169     $args['posts_per_page'] = $a['posts_per_page'];
     176    $albnet_args['posts_per_page'] = $conf['posts_per_page'];
    170177
    171178    /**
    172179     * Current page
    173180     */
    174     $args['paged'] = $a['paged'];
     181    $albnet_args['paged'] = $conf['paged'];
    175182
    176183    /**
    177184     * Check if has paged
    178185     */
    179     if(!$args['paged']) {
     186    if(!$albnet_args['paged']) {
    180187        /**
    181188         * If paged remove offset setting
    182189         */
    183         $args['offset'] = $a['offset'];
     190        $albnet_args['offset'] = $conf['offset'];
    184191    }
    185192
     
    187194     * Show only posts with featured images
    188195     */
    189     if($a['only_with_thumb']) {
    190         $args['meta_query'] = [
     196    if($conf['only_with_thumb']) {
     197        $albnet_args['meta_query'] = [
    191198            [
    192199                'key' => '_thumbnail_id',
     
    199206     * Remove offset setting if is paginated
    200207     */
    201     if($a['paged']) {
    202         unset($args['offset']);
     208    if($conf['paged']) {
     209        unset($albnet_args['offset']);
    203210    }
    204211   
     
    206213     * Check if has fields to filter by taxonomy
    207214     */
    208     if($a['taxonomy'] && $a['field'] && $a['terms']) {
    209         $args['tax_query'] = [
     215    if($conf['taxonomy'] && $conf['field'] && $conf['terms']) {
     216        $albnet_args['tax_query'] = [
    210217            [
    211                 'taxonomy' => $a['taxonomy'],
    212                 'field' => $a['field'],
    213                 'terms' => $a['terms']
     218                'taxonomy' => $conf['taxonomy'],
     219                'field' => $conf['field'],
     220                'terms' => $conf['terms']
    214221            ]
    215222        ];
     
    219226     * Set posts ordering
    220227     */
    221     $args['order'] = $a['order'];
    222     $args['orderby'] = $a['orderby'];
    223 
    224     return $args;
     228    $albnet_args['order'] = $conf['order'];
     229    $albnet_args['orderby'] = $conf['orderby'];
     230
     231    /**
     232     * Query optmizations
     233     */
     234    $albnet_args['no_found_rows'] = true;
     235    $albnet_args['update_post_meta_cache'] = false;
     236    $albnet_args['update_post_term_cache'] = false;
     237    //$albnet_args['fields'] = 'ids';
     238   
     239
     240    return array_filter($albnet_args);
    225241}
  • albnet-shortcodes/trunk/shortcode-horizontal.php

    r2007350 r2007718  
    11<?php defined( 'ABSPATH' ) or die( 'No script kiddies please!' ); ?>
    22<div class="albnet-horizontal albnet-<?php echo $a['terms']; ?>">
     3
    34    <?php
    45   
    56    $args = albnet_get_args($a);   
    6    
     7
    78    $the_query = new WP_Query($args);
    89   
     
    1617        <?php $index = 1; while ( $the_query->have_posts() ) { $the_query->the_post();  ?>
    1718            <?php
    18                 $tipo_video = get_field('tipo_do_video');
    19                 $id_video = get_field('id_video');
    20                 $video_ao_vivo = get_field('ao_vivo');
    21                 $descricao_do_video = get_field('descricao_do_video');
     19                if($a['post_type'] == 'videos'){
     20                    $tipo_video = get_field('tipo_do_video');
     21                    $id_video = get_field('id_video');
     22                    $video_ao_vivo = get_field('ao_vivo');
     23                    $descricao_do_video = get_field('descricao_do_video');
     24                }
    2225            ?>
    2326            <div class="uk-card uk-card-small">
  • albnet-shortcodes/trunk/style.css

    r2007320 r2007718  
    161161    margin: 0
    162162}
     163.uk-card-title {
     164    font-size: 1rem;
     165    position: relative;
     166    top: -2px;
     167}
     168.albnet-horizontal .uk-card-title {
     169    position: relative;
     170    top: -2px;
     171}
     172.albnet-horizontal.albnet-amazonas .uk-card-title {
     173    font-size: 1.7rem
     174}
    163175@media all and (max-width: 980px) {
    164 .box-bordered {
    165 border: none;
    166 padding: 0;
    167 }
     176    .box-bordered {
     177        border: none;
     178        padding: 0;
     179    }
    168180    header {
    169181        padding-right: 10px;
Note: See TracChangeset for help on using the changeset viewer.