Changeset 2509295
- Timestamp:
- 04/05/2021 09:17:25 AM (5 years ago)
- Location:
- ac-custom-loop-shortcode/trunk
- Files:
-
- 4 edited
-
ac-wp-custom-loop-sc.php (modified) (7 diffs)
-
assets/css/ac_wp_custom_loop_styles.css (modified) (1 diff)
-
loop-template.php (modified) (1 diff)
-
readme.txt (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
ac-custom-loop-shortcode/trunk/ac-wp-custom-loop-sc.php
r2217622 r2509295 4 4 Plugin URI: https://github.com/ambercouch/ac-wp-custom-loop-shortcode 5 5 Description: Shortcode ( [ac_custom_loop] ) that allows you to easily list post, pages or custom posts with the WordPress content editor or in any widget that supports short code. A typical use would be to show your latest post on your homepage. 6 Version: 1. 4.36 Version: 1.5 7 7 Author: AmberCouch 8 8 Author URI: http://ambercouch.co.uk … … 26 26 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 27 27 */ 28 29 use Timber\PostQuery; 28 30 29 31 defined('ABSPATH') or die('You do not have the required permissions'); … … 54 56 ), $atts)); 55 57 56 58 $template_type = $type; 57 59 58 60 //default orderby … … 70 72 $type = 'any'; 71 73 $orderby = 'post__in'; 74 72 75 } 73 76 … … 77 80 $output = ''; 78 81 $post_types = get_post_types($args, 'names'); 82 79 83 $theme_directory = $template_path; 80 //$theme_extention = (substr($template, -4) === '.php' || substr($template, -5) === '.twig' ) ? '' : '.php'; 81 $template = (substr($template, -4) === '.php') ? substr_replace($template ,"",-4) : $template; 82 $theme_template = $theme_directory . $template . '.php'; 83 $theme_template_type = $theme_directory . $template . '-' . $type . '.php'; 84 85 86 if ($timber != false){ 87 $twig_template_folder = $theme_directory . 'templates/'; 88 $template = (substr($template, -5) === '.twig') ? substr_replace($template ,"",-5) : $template; 89 $theme_template = $template . '.twig'; 90 $theme_template_type = $template . '-' . $template_type . '.twig'; 91 }else{ 92 93 //$theme_extention = (substr($template, -4) === '.php' || substr($template, -5) === '.twig' ) ? '' : '.php'; 94 $template = (substr($template, -4) === '.php') ? substr_replace($template ,"",-4) : $template; 95 $theme_template = $theme_directory . $template . '.php'; 96 $theme_template_type = $theme_directory . $template . '-' . $template_type . '.php'; 97 } 84 98 85 99 $wrapperOpen = ($wrapper == 'true') ? '<div class="'.$class.'" >' : ''; … … 98 112 } 99 113 100 101 if (file_exists($theme_template_type)) 102 { 103 $template = $theme_template_type; 104 105 }elseif (file_exists( $theme_template )) 106 { 107 $template = $theme_template; 108 109 }else{ 110 $template = "loop-template.php"; 111 } 114 if($timber != false){ 115 116 if (file_exists($twig_template_folder.$theme_template_type)) 117 { 118 $template = $theme_template_type; 119 120 }elseif (file_exists($twig_template_folder.$theme_template )) 121 { 122 $template = $theme_template; 123 }else{ 124 $template = "loop-template.twig"; 125 } 126 }else{ 127 128 if (file_exists($theme_template_type)) 129 { 130 $template = $theme_template_type; 131 132 }elseif (file_exists( $theme_template )) 133 { 134 $template = $theme_template; 135 }else{ 136 $template = "loop-template.php"; 137 } 138 } 112 139 113 140 if (!in_array($type, $post_types) && $type != 'any') … … 163 190 164 191 }else{ 165 $context = Timber::get_context(); 166 $context['posts'] = Timber::get_posts(); 167 $templates = array('loop-template.twig'); 168 ob_start(); 169 Timber::render( $templates, $context ); 170 $output .= ob_get_contents(); 171 ob_end_clean(); 192 if(class_exists('Timber')){ 193 194 $context = Timber::get_context(); 195 $context['posts'] = new Timber\PostQuery(); 196 $templates = array( $template); 197 ob_start(); 198 Timber::render( $templates, $context ); 199 $output .= ob_get_contents(); 200 ob_end_clean(); 201 }else{ 202 ob_start(); 203 ?> 204 <?php echo "<p>The Timber plugin is not active.<br> Activate Timber or set <code>timber='false'</code> in the short code</p>" ?> 205 <?php 206 $output .= ob_get_contents(); 207 ob_end_clean(); 208 } 209 172 210 } 173 211 $output .= $wrapperClose; -
ac-custom-loop-shortcode/trunk/assets/css/ac_wp_custom_loop_styles.css
r1957421 r2509295 13 13 float: none; 14 14 display: block; 15 padding: 0.25em 0.5em !important; 16 } 17 .c-accl-post-thumb__heading{ 18 font-size: 1em !important; 19 margin: 1em 0 !important; 20 } 21 22 .c-accl-post-thumb__feature-image img{ 23 max-width: 100%; 24 height: auto; 15 25 } 16 26 -
ac-custom-loop-shortcode/trunk/loop-template.php
r2206142 r2509295 7 7 */ 8 8 9 $handle = 'ac_wp_custom_loop_styles';10 $list = 'enqueued';11 9 12 if (! wp_script_is( $handle, $list )) {13 wp_register_style( 'ac_wp_custom_loop_styles', plugin_dir_url( __FILE__ ) . 'assets/css/ac_wp_custom_loop_styles.css', array(), '20181007' );14 wp_enqueue_style( 'ac_wp_custom_loop_styles' );15 }16 10 ?> 17 11 -
ac-custom-loop-shortcode/trunk/readme.txt
r2217622 r2509295 4 4 Tags: shortcode, list post, list custom posts, timber, twig, custom post type 5 5 Requires at least: 4.6 6 Tested up to: 5. 3.27 Stable tag: 1. 4.36 Tested up to: 5.7 7 Stable tag: 1.5 8 8 Requires PHP: 5.2.4 9 9 License: GPLv2 or later … … 40 40 == Upgrade Notice == 41 41 42 = 1.5 = 43 Updated Timber support. 44 42 45 = 1.4.3 = 43 46 Fix release issues. … … 59 62 60 63 == Changelog == 64 65 = 1.5 (2021-04-04) = 66 * Fix release issues. 61 67 62 68 = 1.4.3 (2019-12-06) =
Note: See TracChangeset
for help on using the changeset viewer.