Version Description
- New: Date variables can noe be added into shortcode content.
- Fix: Error "trying to get property of non-object" is handled.
Download this release
Release Info
Developer | vaakash |
Plugin | Shortcoder |
Version | 4.1.6 |
Comparing to | |
See all releases |
Code changes from version 4.1.5 to 4.1.6
- admin/sc-admin.php +11 -4
- includes/metadata.php +25 -8
- readme.txt +6 -2
- shortcoder.php +50 -25
admin/sc-admin.php
CHANGED
@@ -268,11 +268,16 @@ class Shortcoder_Admin{
|
|
268 |
$sc_wp_params = Shortcoder::wp_params_list();
|
269 |
|
270 |
echo '<ul class="params_wrap">';
|
271 |
-
|
272 |
-
foreach( $sc_wp_params as $
|
273 |
-
echo '<li
|
|
|
|
|
|
|
|
|
|
|
274 |
}
|
275 |
-
|
276 |
echo '<li>' . __( 'Custom parameter', 'shortcoder' ) . '<ul>';
|
277 |
echo '<li class="cp_form"><h4>' . __( 'Enter custom parameter name', 'shortcoder' ) . '</h4>';
|
278 |
echo '<input type="text" class="cp_box" pattern="[a-zA-Z0-9]+"/> <button class="button cp_btn">' . __( 'Insert parameter', 'shortcoder' ) . '</button><p class="cp_info"><small>' . __( 'Only alphabets and numbers allowed. Custom parameters are case insensitive', 'shortcoder' ) . '</small></p></li>';
|
@@ -402,6 +407,7 @@ class Shortcoder_Admin{
|
|
402 |
|
403 |
array_push( $buttons, 'separator', 'shortcoder' );
|
404 |
return $buttons;
|
|
|
405 |
}
|
406 |
|
407 |
public static function register_mce_js( $plugins ){
|
@@ -411,6 +417,7 @@ class Shortcoder_Admin{
|
|
411 |
|
412 |
$plugins[ 'shortcoder' ] = SC_ADMIN_URL . '/js/tinymce/editor_plugin.js';
|
413 |
return $plugins;
|
|
|
414 |
}
|
415 |
|
416 |
public static function load_codemirror_editor( $value ){
|
268 |
$sc_wp_params = Shortcoder::wp_params_list();
|
269 |
|
270 |
echo '<ul class="params_wrap">';
|
271 |
+
|
272 |
+
foreach( $sc_wp_params as $group => $group_info ){
|
273 |
+
echo '<li>' . $group_info[ 'name' ];
|
274 |
+
echo '<ul class="wp_params">';
|
275 |
+
foreach( $group_info[ 'params' ] as $param_id => $param_name ){
|
276 |
+
echo '<li data-id="' . $param_id . '">' . $param_name . '</li>';
|
277 |
+
}
|
278 |
+
echo '</ul></li>';
|
279 |
}
|
280 |
+
|
281 |
echo '<li>' . __( 'Custom parameter', 'shortcoder' ) . '<ul>';
|
282 |
echo '<li class="cp_form"><h4>' . __( 'Enter custom parameter name', 'shortcoder' ) . '</h4>';
|
283 |
echo '<input type="text" class="cp_box" pattern="[a-zA-Z0-9]+"/> <button class="button cp_btn">' . __( 'Insert parameter', 'shortcoder' ) . '</button><p class="cp_info"><small>' . __( 'Only alphabets and numbers allowed. Custom parameters are case insensitive', 'shortcoder' ) . '</small></p></li>';
|
407 |
|
408 |
array_push( $buttons, 'separator', 'shortcoder' );
|
409 |
return $buttons;
|
410 |
+
|
411 |
}
|
412 |
|
413 |
public static function register_mce_js( $plugins ){
|
417 |
|
418 |
$plugins[ 'shortcoder' ] = SC_ADMIN_URL . '/js/tinymce/editor_plugin.js';
|
419 |
return $plugins;
|
420 |
+
|
421 |
}
|
422 |
|
423 |
public static function load_codemirror_editor( $value ){
|
includes/metadata.php
CHANGED
@@ -37,7 +37,18 @@ class Shortcoder_Metadata{
|
|
37 |
'stylesheet_directory' => get_bloginfo( 'stylesheet_directory' ),
|
38 |
'template_url' => get_bloginfo( 'template_url' ),
|
39 |
'atom_url' => get_bloginfo( 'atom_url' ),
|
40 |
-
'rss_url' => get_bloginfo( 'rss2_url' )
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
41 |
|
42 |
);
|
43 |
|
@@ -62,7 +73,9 @@ class Shortcoder_Metadata{
|
|
62 |
|
63 |
}elseif( is_singular() ){
|
64 |
|
65 |
-
|
|
|
|
|
66 |
|
67 |
}elseif( is_tax() || is_tag() || is_category() ){
|
68 |
|
@@ -143,8 +156,6 @@ class Shortcoder_Metadata{
|
|
143 |
|
144 |
public static function meta_by_id( $id ){
|
145 |
|
146 |
-
global $post;
|
147 |
-
|
148 |
$d = array();
|
149 |
|
150 |
if( $id ){
|
@@ -154,7 +165,7 @@ class Shortcoder_Metadata{
|
|
154 |
'short_url' => wp_get_shortlink( $id ),
|
155 |
|
156 |
'post_id' => $id,
|
157 |
-
'post_excerpt' => self::excerpt(
|
158 |
'post_comments_count' => get_comments_number( $id ),
|
159 |
'post_image' => self::post_image( $id ),
|
160 |
'post_author' => get_the_author(),
|
@@ -170,12 +181,18 @@ class Shortcoder_Metadata{
|
|
170 |
|
171 |
}
|
172 |
|
173 |
-
public static function excerpt( $
|
174 |
|
175 |
global $post;
|
176 |
|
177 |
-
|
178 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
179 |
|
180 |
}
|
181 |
|
37 |
'stylesheet_directory' => get_bloginfo( 'stylesheet_directory' ),
|
38 |
'template_url' => get_bloginfo( 'template_url' ),
|
39 |
'atom_url' => get_bloginfo( 'atom_url' ),
|
40 |
+
'rss_url' => get_bloginfo( 'rss2_url' ),
|
41 |
+
|
42 |
+
'day' => current_time( 'j' ),
|
43 |
+
'day_lz' => current_time( 'd' ),
|
44 |
+
'day_ws' => current_time( 'D' ),
|
45 |
+
'day_wf' => current_time( 'l' ),
|
46 |
+
'month' => current_time( 'n' ),
|
47 |
+
'month_lz' => current_time( 'm' ),
|
48 |
+
'month_ws' => current_time( 'M' ),
|
49 |
+
'month_wf' => current_time( 'F' ),
|
50 |
+
'year' => current_time( 'Y' ),
|
51 |
+
'year_2d' => current_time( 'y' ),
|
52 |
|
53 |
);
|
54 |
|
73 |
|
74 |
}elseif( is_singular() ){
|
75 |
|
76 |
+
if( is_object( $post ) ){
|
77 |
+
$d = self::meta_by_id( $post->ID );
|
78 |
+
}
|
79 |
|
80 |
}elseif( is_tax() || is_tag() || is_category() ){
|
81 |
|
156 |
|
157 |
public static function meta_by_id( $id ){
|
158 |
|
|
|
|
|
159 |
$d = array();
|
160 |
|
161 |
if( $id ){
|
165 |
'short_url' => wp_get_shortlink( $id ),
|
166 |
|
167 |
'post_id' => $id,
|
168 |
+
'post_excerpt' => self::excerpt( 100 ),
|
169 |
'post_comments_count' => get_comments_number( $id ),
|
170 |
'post_image' => self::post_image( $id ),
|
171 |
'post_author' => get_the_author(),
|
181 |
|
182 |
}
|
183 |
|
184 |
+
public static function excerpt( $length = 250 ){
|
185 |
|
186 |
global $post;
|
187 |
|
188 |
+
if( !is_object( $post ) ){
|
189 |
+
return '';
|
190 |
+
}
|
191 |
+
|
192 |
+
$excerpt = $post->post_excerpt; // using $post->post_excerpt instead of get_the_excerpt as the_content filter loses shortcode formatting
|
193 |
+
|
194 |
+
$excerpt_text = ( empty( $excerpt ) ) ? strip_tags( strip_shortcodes( $post->post_content ) ) : $excerpt;
|
195 |
+
return substr( $excerpt_text, 0, $length );
|
196 |
|
197 |
}
|
198 |
|
readme.txt
CHANGED
@@ -6,8 +6,8 @@ Tags: shortcode, html, javascript, shortcodes, short code, posts, pages, widgets
|
|
6 |
Donate link: https://goo.gl/qMF3iE
|
7 |
License: GPLv2 or later
|
8 |
Requires at least: 3.3
|
9 |
-
Tested up to: 4.9.
|
10 |
-
Stable tag: 4.1.
|
11 |
|
12 |
Create custom "Shortcodes" easily for HTML, JavaScript snippets and use the shortcodes within posts, pages & widgets.
|
13 |
|
@@ -91,6 +91,10 @@ Note: When you disable a shortcode, the shortcode will not be executed in the pa
|
|
91 |
|
92 |
== Changelog ==
|
93 |
|
|
|
|
|
|
|
|
|
94 |
= 4.1.5 =
|
95 |
* New: Bloginfo variables can now be added into shortcode content.
|
96 |
|
6 |
Donate link: https://goo.gl/qMF3iE
|
7 |
License: GPLv2 or later
|
8 |
Requires at least: 3.3
|
9 |
+
Tested up to: 4.9.4
|
10 |
+
Stable tag: 4.1.6
|
11 |
|
12 |
Create custom "Shortcodes" easily for HTML, JavaScript snippets and use the shortcodes within posts, pages & widgets.
|
13 |
|
91 |
|
92 |
== Changelog ==
|
93 |
|
94 |
+
= 4.1.6 =
|
95 |
+
* New: Date variables can noe be added into shortcode content.
|
96 |
+
* Fix: Error "trying to get property of non-object" is handled.
|
97 |
+
|
98 |
= 4.1.5 =
|
99 |
* New: Bloginfo variables can now be added into shortcode content.
|
100 |
|
shortcoder.php
CHANGED
@@ -4,11 +4,11 @@ Plugin Name: Shortcoder
|
|
4 |
Plugin URI: https://www.aakashweb.com/
|
5 |
Description: Shortcoder is a plugin which allows to create a custom shortcode and store HTML, JavaScript and other snippets in it. So if that shortcode is used in any post or pages, then the code stored in the shortcode get executed in that place. You can create a shortcode for Youtube videos, adsense ads, buttons and more.
|
6 |
Author: Aakash Chakravarthy
|
7 |
-
Version: 4.1.
|
8 |
Author URI: https://www.aakashweb.com/
|
9 |
*/
|
10 |
|
11 |
-
define( 'SC_VERSION', '4.1.
|
12 |
define( 'SC_PATH', plugin_dir_path( __FILE__ ) ); // All have trailing slash
|
13 |
define( 'SC_URL', plugin_dir_url( __FILE__ ) );
|
14 |
define( 'SC_ADMIN_URL', trailingslashit( plugin_dir_url( __FILE__ ) . 'admin' ) );
|
@@ -153,10 +153,16 @@ class Shortcoder{
|
|
153 |
public static function replace_wp_params( $content ){
|
154 |
|
155 |
$params = self::wp_params_list();
|
|
|
|
|
|
|
|
|
|
|
|
|
156 |
$metadata = Shortcoder_Metadata::metadata();
|
157 |
$to_replace = array();
|
158 |
|
159 |
-
foreach( $
|
160 |
if( array_key_exists( $id, $metadata ) ){
|
161 |
$placeholder = '$$' . $id . '$$';
|
162 |
$to_replace[ $placeholder ] = $metadata[ $id ];
|
@@ -171,28 +177,47 @@ class Shortcoder{
|
|
171 |
|
172 |
public static function wp_params_list(){
|
173 |
return apply_filters( 'sc_mod_wp_params', array(
|
174 |
-
'
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
196 |
));
|
197 |
}
|
198 |
|
4 |
Plugin URI: https://www.aakashweb.com/
|
5 |
Description: Shortcoder is a plugin which allows to create a custom shortcode and store HTML, JavaScript and other snippets in it. So if that shortcode is used in any post or pages, then the code stored in the shortcode get executed in that place. You can create a shortcode for Youtube videos, adsense ads, buttons and more.
|
6 |
Author: Aakash Chakravarthy
|
7 |
+
Version: 4.1.6
|
8 |
Author URI: https://www.aakashweb.com/
|
9 |
*/
|
10 |
|
11 |
+
define( 'SC_VERSION', '4.1.6' );
|
12 |
define( 'SC_PATH', plugin_dir_path( __FILE__ ) ); // All have trailing slash
|
13 |
define( 'SC_URL', plugin_dir_url( __FILE__ ) );
|
14 |
define( 'SC_ADMIN_URL', trailingslashit( plugin_dir_url( __FILE__ ) . 'admin' ) );
|
153 |
public static function replace_wp_params( $content ){
|
154 |
|
155 |
$params = self::wp_params_list();
|
156 |
+
$all_params = array();
|
157 |
+
|
158 |
+
foreach( $params as $group => $group_info ){
|
159 |
+
$all_params = array_merge( $group_info[ 'params' ], $all_params );
|
160 |
+
}
|
161 |
+
|
162 |
$metadata = Shortcoder_Metadata::metadata();
|
163 |
$to_replace = array();
|
164 |
|
165 |
+
foreach( $all_params as $id => $name ){
|
166 |
if( array_key_exists( $id, $metadata ) ){
|
167 |
$placeholder = '$$' . $id . '$$';
|
168 |
$to_replace[ $placeholder ] = $metadata[ $id ];
|
177 |
|
178 |
public static function wp_params_list(){
|
179 |
return apply_filters( 'sc_mod_wp_params', array(
|
180 |
+
'wp_info' => array(
|
181 |
+
'name' => __( 'WordPress information', 'shortcoder' ),
|
182 |
+
'params' => array(
|
183 |
+
'url' => __( 'URL of the post/location', 'shortcoder' ),
|
184 |
+
'title' => __( 'Title of the post/location', 'shortcoder' ),
|
185 |
+
'short_url' => __( 'Short URL of the post/location', 'shortcoder' ),
|
186 |
+
|
187 |
+
'post_id' => __( 'Post ID', 'shortcoder' ),
|
188 |
+
'post_image' => __( 'Post featured image URL', 'shortcoder' ),
|
189 |
+
'post_excerpt' => __( 'Post excerpt', 'shortcoder' ),
|
190 |
+
'post_author' => __( 'Post author', 'shortcoder' ),
|
191 |
+
'post_date' => __( 'Post date', 'shortcoder' ),
|
192 |
+
'post_comments_count' => __( 'Post comments count', 'shortcoder' ),
|
193 |
+
|
194 |
+
'site_name' => __( 'Site title', 'shortcoder' ),
|
195 |
+
'site_description' => __( 'Site description', 'shortcoder' ),
|
196 |
+
'site_url' => __( 'Site URL', 'shortcoder' ),
|
197 |
+
'site_wpurl' => __( 'WordPress URL', 'shortcoder' ),
|
198 |
+
'site_charset' => __( 'Site character set', 'shortcoder' ),
|
199 |
+
'wp_version' => __( 'WordPress version', 'shortcoder' ),
|
200 |
+
'stylesheet_url' => __( 'Active theme\'s stylesheet URL', 'shortcoder' ),
|
201 |
+
'stylesheet_directory' => __( 'Active theme\'s directory', 'shortcoder' ),
|
202 |
+
'atom_url' => __( 'Atom feed URL', 'shortcoder' ),
|
203 |
+
'rss_url' => __( 'RSS 2.0 feed URL', 'shortcoder' )
|
204 |
+
)
|
205 |
+
),
|
206 |
+
'date_info' => array(
|
207 |
+
'name' => __( 'Date parameters', 'shortcoder' ),
|
208 |
+
'params' => array(
|
209 |
+
'day' => __( 'Day', 'shortcoder' ),
|
210 |
+
'day_lz' => __( 'Day - leading zeros', 'shortcoder' ),
|
211 |
+
'day_ws' => __( 'Day - words - short form', 'shortcoder' ),
|
212 |
+
'day_wf' => __( 'Day - words - full form', 'shortcoder' ),
|
213 |
+
'month' => __( 'Month', 'shortcoder' ),
|
214 |
+
'month_lz' => __( 'Month - leading zeros', 'shortcoder' ),
|
215 |
+
'month_ws' => __( 'Month - words - short form', 'shortcoder' ),
|
216 |
+
'month_wf' => __( 'Month - words - full form', 'shortcoder' ),
|
217 |
+
'year' => __( 'Year', 'shortcoder' ),
|
218 |
+
'year_2d' => __( 'Year - 2 digit', 'shortcoder' ),
|
219 |
+
)
|
220 |
+
)
|
221 |
));
|
222 |
}
|
223 |
|