Post Snippets - Version 3.0.5

Version Description

Download this release

Release Info

Developer davdebcom
Plugin Icon 128x128 Post Snippets
Version 3.0.5
Comparing to
See all releases

Code changes from version 3.0.4 to 3.0.5

assets/post-snippets.css CHANGED
@@ -70,7 +70,7 @@
70
 
71
 
72
  /** Fix for when editors (TinyMCE Advanced) stack above the PS dialog **/
73
- .ui-dialog { z-index: 1000 !important ;}
74
 
75
  #post-snippets-dialog label {
76
  width: 60px;
@@ -98,6 +98,16 @@
98
  box-shadow: none !important;
99
  border:none !important;
100
  }
 
 
 
 
 
 
 
 
 
 
101
  .post-snippets-item {
102
  background: #efefef;
103
  margin-bottom: 10px;
70
 
71
 
72
  /** Fix for when editors (TinyMCE Advanced) stack above the PS dialog **/
73
+ .ui-dialog { z-index: 10000000 !important ;}
74
 
75
  #post-snippets-dialog label {
76
  width: 60px;
98
  box-shadow: none !important;
99
  border:none !important;
100
  }
101
+
102
+ .post-snippets-list-empty p {
103
+ background: #efefef;
104
+ border: 1px solid #d8d6d6;
105
+ text-align: center;
106
+ font-size: 25px;
107
+ padding: 35px 150px;
108
+ margin: 10px;
109
+ }
110
+
111
  .post-snippets-item {
112
  background: #efefef;
113
  margin-bottom: 10px;
assets/post-snippets.js CHANGED
@@ -1,4 +1,22 @@
1
  jQuery(document).ready(function ($) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2
  /**
3
  * Loops through all snippets when page has loaded.
4
  */
1
  jQuery(document).ready(function ($) {
2
+ /**
3
+ * Check if there are any snippets
4
+ */
5
+ if (document.getElementsByClassName("post-snippets-item").length == 0) {
6
+ $(this).find(".post-snippets-list-empty").show();
7
+ $(this).find(".post-snippets-buttons-bottom").hide();
8
+ $(this).find(".post-snippets-table .expand-all").hide();
9
+ $(this).find(".post-snippets-table .collapse-all").hide();
10
+
11
+ $( 'input[name=update-snippets]' ).attr('class', 'button-secondary');
12
+ $( 'input[name=add-snippet]' ).attr('class', 'button-primary');
13
+
14
+ (function pulse(){
15
+ $( 'input[name=add-snippet]' ).first().delay(200).animate({'opacity':1}).delay(2000).animate({'opacity':0},pulse);
16
+ })();
17
+
18
+ }
19
+
20
  /**
21
  * Loops through all snippets when page has loaded.
22
  */
freemius/assets/img/post-snippets.png ADDED
Binary file
post-snippets.php CHANGED
@@ -3,18 +3,18 @@
3
  /**
4
  * Post Snippets
5
  *
6
- * @package PS
7
- * @author David de Boer <david@davdeb.com>
8
- * @license GPL-2.0+
9
- * @link https://www.postsnippets.com
10
- * @copyright 2017 David de Boer
11
- * @copyright 2009-2017 Johan Steen
12
  *
13
  * @wordpress-plugin
14
  * Plugin Name: Post Snippets
15
  * Plugin URI: https://www.postsnippets.com
16
  * Description: Create a library of reusable content and insert it into your posts and pages. Navigate to "Settings > Post Snippets" to get started.
17
- * Version: 3.0.4
18
  * Author: David de Boer
19
  * Author URI: https://www.postsnippets.com
20
  * License: GPL-2.0+
@@ -24,263 +24,289 @@
24
  *
25
  * @fs_premium_only /assets/post-snippets-pro.js,
26
  */
27
- // Create a helper function for easy SDK access.
28
- function postsnippets_fs()
29
- {
30
- global $postsnippets_fs ;
31
-
32
- if ( !isset( $postsnippets_fs ) ) {
33
- // Include Freemius SDK.
34
- require_once dirname( __FILE__ ) . '/freemius/start.php';
35
- $postsnippets_fs = fs_dynamic_init( array(
36
- 'id' => '1576',
37
- 'slug' => 'post-snippets',
38
- 'type' => 'plugin',
39
- 'public_key' => 'pk_58a2ec84c44485a459aae07bfaf5f',
40
- 'is_premium' => false,
41
- 'has_addons' => false,
42
- 'has_paid_plans' => true,
43
- 'trial' => array(
44
- 'days' => 7,
45
- 'is_require_payment' => false,
46
- ),
47
- 'menu' => array(
48
- 'slug' => 'post-snippets/post-snippets.php',
49
- 'override_exact' => true,
50
- 'contact' => true,
51
- 'account' => true,
52
- 'support' => true,
53
- 'parent' => array(
54
- 'slug' => 'options-general.php',
55
- ),
56
- ),
57
- 'is_live' => true,
58
- ) );
59
- }
60
-
61
- return $postsnippets_fs;
62
- }
63
-
64
- // Init Freemius.
65
- postsnippets_fs();
66
- // Signal that SDK was initiated.
67
- do_action( 'postsnippets_fs_loaded' );
68
- function postsnippets_fs_settings_url()
69
- {
70
- return admin_url( 'options-general.php?page=post-snippets%2Fpost-snippets.php' );
71
- }
72
 
73
- postsnippets_fs()->add_filter( 'connect_url', 'postsnippets_fs_settings_url' );
74
- postsnippets_fs()->add_filter( 'after_skip_url', 'postsnippets_fs_settings_url' );
75
- postsnippets_fs()->add_filter( 'after_connect_url', 'postsnippets_fs_settings_url' );
76
- postsnippets_fs()->add_filter( 'after_pending_connect_url', 'postsnippets_fs_settings_url' );
77
- /** Load all of the necessary class files for the plugin */
78
- spl_autoload_register( 'PostSnippets::autoload' );
79
- if ( !defined( 'PS_MAIN_FILE' ) ) {
80
- define( 'PS_MAIN_FILE', basename( __FILE__ ) );
81
- }
82
- if ( !defined( 'PS_VERSION' ) ) {
83
- define( 'PS_VERSION', '3.0.2' );
84
- }
85
- if ( !defined( 'PS_MAIN_FILE_PATH' ) ) {
86
- define( 'PS_MAIN_FILE_PATH', __FILE__ );
87
- }
88
- if ( !defined( 'PS_DIRECTORY' ) ) {
89
- define( 'PS_DIRECTORY', plugin_basename( dirname( __FILE__ ) ) );
90
- }
91
- if ( !defined( 'PS_PATH' ) ) {
92
- define( 'PS_PATH', plugin_dir_path( __FILE__ ) );
93
- }
94
- if ( !defined( 'PS_URL' ) ) {
95
- define( 'PS_URL', plugins_url( '', __FILE__ ) . '/' );
96
- }
97
- if ( !defined( 'PS_MAIN_PAGE_URL' ) ) {
98
- define( 'PS_MAIN_PAGE_URL', esc_url( admin_url( 'options-general.php?page=' . PS_DIRECTORY . '/' . PS_MAIN_FILE ) ) );
99
- }
100
- class PostSnippets
101
- {
102
- /** Holds the plugin instance */
103
- private static $instance = false ;
104
- /** Define plugin constants */
105
- const MIN_PHP_VERSION = '5.3.0' ;
106
- const MIN_WP_VERSION = '3.3' ;
107
- const SETTINGS = 'post_snippets' ;
108
- const OPTION_KEY = 'post_snippets_options' ;
109
- const USER_META_KEY = 'post_snippets' ;
110
- const FILE = __FILE__ ;
111
- /**
112
- * Singleton class
113
- */
114
- public static function getInstance()
115
  {
116
- if ( !self::$instance ) {
117
- self::$instance = new self();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
118
  }
119
- return self::$instance;
 
120
  }
121
 
 
 
 
 
 
 
 
 
 
 
 
 
 
122
  /**
123
- * Initializes the plugin.
124
  */
125
- private function __construct()
126
  {
127
- if ( !$this->testHost() ) {
128
- return;
 
 
129
  }
130
- load_plugin_textdomain( 'post-snippets', false, dirname( plugin_basename( __FILE__ ) ) . '/lang/' );
131
- add_action( 'after_setup_theme', array( &$this, 'phpExecState' ) );
132
- new \PostSnippets\Admin();
133
- new \PostSnippets\WPEditor();
134
- new \PostSnippets\Shortcode();
135
  }
136
 
137
- /**
138
- * PSR-0 compliant autoloader to load classes as needed.
139
- *
140
- * @param string $classname
141
- * @return void
142
- */
143
- public static function autoload( $className )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
144
  {
145
- if ( __CLASS__ !== mb_substr( $className, 0, strlen( __CLASS__ ) ) ) {
146
- return;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
147
  }
148
- $className = ltrim( $className, '\\' );
149
- $fileName = '';
150
- $namespace = '';
151
 
152
- if ( $lastNsPos = strrpos( $className, '\\' ) ) {
153
- $namespace = substr( $className, 0, $lastNsPos );
154
- $className = substr( $className, $lastNsPos + 1 );
155
- $fileName = str_replace( '\\', DIRECTORY_SEPARATOR, $namespace );
156
- $fileName .= DIRECTORY_SEPARATOR;
 
 
 
 
 
 
 
 
157
  }
158
 
159
- $fileName .= str_replace( '_', DIRECTORY_SEPARATOR, $className );
160
- require 'src' . DIRECTORY_SEPARATOR . $fileName . '.php';
161
- }
162
-
163
- // -------------------------------------------------------------------------
164
- // Helpers
165
- // -------------------------------------------------------------------------
166
- /**
167
- * Allow snippets to be retrieved directly from PHP.
168
- *
169
- * @since Post Snippets 1.8.9.1
170
- *
171
- * @param string $name The name of the snippet to retrieve
172
- * @param string|array $variables The variables to pass to the snippet,
173
- * formatted as a query string or an associative array.
174
- * @return string The Snippet
175
- */
176
- public static function getSnippet( $name, $variables = '' )
177
- {
178
- $snippets = get_option( self::OPTION_KEY, array() );
179
- for ( $i = 0 ; $i < count( $snippets ) ; $i++ ) {
180
 
181
- if ( $snippets[$i]['title'] == $name ) {
182
- if ( !is_array( $variables ) ) {
183
- parse_str( htmlspecialchars_decode( $variables ), $variables );
184
- }
185
- $snippet = $snippets[$i]['snippet'];
186
- $var_arr = explode( ",", $snippets[$i]['vars'] );
187
- if ( !empty($var_arr[0]) ) {
188
- for ( $j = 0 ; $j < count( $var_arr ) ; $j++ ) {
189
- $snippet = str_replace( "{" . $var_arr[$j] . "}", $variables[$var_arr[$j]], $snippet );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
190
  }
 
191
  }
192
- break;
193
  }
 
 
194
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
195
  }
196
- return do_shortcode( $snippet );
197
- }
198
-
199
- // -------------------------------------------------------------------------
200
- // Environment Checks
201
- // -------------------------------------------------------------------------
202
- /**
203
- * Checks PHP and WordPress versions.
204
- */
205
- private function testHost()
206
- {
207
- // Check if PHP is too old
208
 
209
- if ( version_compare( PHP_VERSION, self::MIN_PHP_VERSION, '<' ) ) {
210
- // Display notice
211
- add_action( 'admin_notices', array( &$this, 'phpVersionError' ) );
212
- return false;
 
 
 
 
 
 
 
 
 
213
  }
214
 
215
- // Check if WordPress is too old
216
- global $wp_version ;
 
 
 
 
 
 
 
217
 
218
- if ( version_compare( $wp_version, self::MIN_WP_VERSION, '<' ) ) {
219
- add_action( 'admin_notices', array( &$this, 'wpVersionError' ) );
220
- return false;
 
 
 
 
 
 
221
  }
222
 
223
- return true;
224
- }
225
-
226
- /**
227
- * Displays a warning when installed on an old PHP version.
228
- */
229
- public function phpVersionError()
230
- {
231
- echo '<div class="error"><p><strong>' ;
232
- printf(
233
- 'Error: %3$s requires PHP version %1$s or greater.<br/>' . 'Your installed PHP version: %2$s',
234
- self::MIN_PHP_VERSION,
235
- PHP_VERSION,
236
- $this->getPluginName()
237
- );
238
- echo '</strong></p></div>' ;
239
- }
240
-
241
- /**
242
- * Displays a warning when installed in an old WordPress version.
243
- */
244
- public function wpVersionError()
245
- {
246
- echo '<div class="error"><p><strong>' ;
247
- printf( 'Error: %2$s requires WordPress version %1$s or greater.', self::MIN_WP_VERSION, $this->getPluginName() );
248
- echo '</strong></p></div>' ;
249
- }
250
-
251
- /**
252
- * Get the name of this plugin.
253
- *
254
- * @return string The plugin name.
255
- */
256
- private function getPluginName()
257
- {
258
- $data = get_plugin_data( self::FILE );
259
- return $data['Name'];
260
- }
261
-
262
- // -------------------------------------------------------------------------
263
- // Deprecated methods
264
- // -------------------------------------------------------------------------
265
- /**
266
- * Allow plugins to disable the PHP Code execution feature with a filter.
267
- * Deprecated: Use the POST_SNIPPETS_DISABLE_PHP global constant to disable
268
- * PHP instead.
269
- *
270
- * @see http://wordpress.org/extend/plugins/post-snippets/faq/
271
- * @since 2.1
272
- * @deprecated 2.3
273
- */
274
- public function phpExecState()
275
- {
276
- $filter = apply_filters( 'post_snippets_php_execution_enabled', true );
277
 
278
- if ( $filter == false and !defined( 'POST_SNIPPETS_DISABLE_PHP' ) ) {
279
- _deprecated_function( 'post_snippets_php_execution_enabled', '2.3', 'define(\'POST_SNIPPETS_DISABLE_PHP\', true);' );
280
- define( 'POST_SNIPPETS_DISABLE_PHP', true );
281
  }
282
 
283
  }
284
-
 
 
 
 
285
  }
286
- add_action( 'plugins_loaded', array( 'PostSnippets', 'getInstance' ) );
3
  /**
4
  * Post Snippets
5
  *
6
+ * @package PS
7
+ * @author David de Boer <david@davdeb.com>
8
+ * @license GPL-2.0+
9
+ * @link https://www.postsnippets.com
10
+ * @copyright 2017-2018 David de Boer
11
+ * @copyright 2009-2017 Johan Steen
12
  *
13
  * @wordpress-plugin
14
  * Plugin Name: Post Snippets
15
  * Plugin URI: https://www.postsnippets.com
16
  * Description: Create a library of reusable content and insert it into your posts and pages. Navigate to "Settings > Post Snippets" to get started.
17
+ * Version: 3.0.5
18
  * Author: David de Boer
19
  * Author URI: https://www.postsnippets.com
20
  * License: GPL-2.0+
24
  *
25
  * @fs_premium_only /assets/post-snippets-pro.js,
26
  */
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
27
 
28
+ if ( !function_exists( 'postsnippets_fs' ) ) {
29
+ // Create a helper function for easy SDK access.
30
+ function postsnippets_fs()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
31
  {
32
+ global $postsnippets_fs ;
33
+
34
+ if ( !isset( $postsnippets_fs ) ) {
35
+ // Include Freemius SDK.
36
+ require_once dirname( __FILE__ ) . '/freemius/start.php';
37
+ $postsnippets_fs = fs_dynamic_init( array(
38
+ 'id' => '1576',
39
+ 'slug' => 'post-snippets',
40
+ 'type' => 'plugin',
41
+ 'public_key' => 'pk_58a2ec84c44485a459aae07bfaf5f',
42
+ 'is_premium' => false,
43
+ 'has_addons' => false,
44
+ 'has_paid_plans' => true,
45
+ 'trial' => array(
46
+ 'days' => 7,
47
+ 'is_require_payment' => false,
48
+ ),
49
+ 'menu' => array(
50
+ 'slug' => 'post-snippets',
51
+ 'override_exact' => true,
52
+ 'contact' => false,
53
+ 'account' => true,
54
+ 'support' => false,
55
+ 'parent' => array(
56
+ 'slug' => 'options-general.php',
57
+ ),
58
+ ),
59
+ 'is_live' => true,
60
+ ) );
61
  }
62
+
63
+ return $postsnippets_fs;
64
  }
65
 
66
+ // Init Freemius.
67
+ postsnippets_fs();
68
+ // Signal that SDK was initiated.
69
+ do_action( 'postsnippets_fs_loaded' );
70
+ function postsnippets_fs_settings_url()
71
+ {
72
+ return admin_url( 'options-general.php?page=post-snippets' );
73
+ }
74
+
75
+ postsnippets_fs()->add_filter( 'connect_url', 'postsnippets_fs_settings_url' );
76
+ postsnippets_fs()->add_filter( 'after_skip_url', 'postsnippets_fs_settings_url' );
77
+ postsnippets_fs()->add_filter( 'after_connect_url', 'postsnippets_fs_settings_url' );
78
+ postsnippets_fs()->add_filter( 'after_pending_connect_url', 'postsnippets_fs_settings_url' );
79
  /**
80
+ * Only show Post Snippets submenu when PS is open, not on all Settings pages
81
  */
82
+ function postsnippets_show_submenu( $is_visible )
83
  {
84
+ if ( isset( $_REQUEST['page'] ) ) {
85
+ if ( $is_visible && false !== strpos( $_REQUEST['page'], 'post-snippets' ) ) {
86
+ return true;
87
+ }
88
  }
89
+ return false;
 
 
 
 
90
  }
91
 
92
+ postsnippets_fs()->add_filter(
93
+ 'is_submenu_visible',
94
+ 'postsnippets_show_submenu',
95
+ 10,
96
+ 2
97
+ );
98
+ if ( !defined( 'PS_MAIN_FILE' ) ) {
99
+ define( 'PS_MAIN_FILE', basename( __FILE__ ) );
100
+ }
101
+ if ( !defined( 'PS_VERSION' ) ) {
102
+ define( 'PS_VERSION', '3.0.2' );
103
+ }
104
+ if ( !defined( 'PS_MAIN_FILE_PATH' ) ) {
105
+ define( 'PS_MAIN_FILE_PATH', __FILE__ );
106
+ }
107
+ if ( !defined( 'PS_DIRECTORY' ) ) {
108
+ define( 'PS_DIRECTORY', plugin_basename( dirname( __FILE__ ) ) );
109
+ }
110
+ if ( !defined( 'PS_PATH' ) ) {
111
+ define( 'PS_PATH', plugin_dir_path( __FILE__ ) );
112
+ }
113
+ if ( !defined( 'PS_URL' ) ) {
114
+ define( 'PS_URL', plugins_url( '', __FILE__ ) . '/' );
115
+ }
116
+ if ( !defined( 'PS_MAIN_PAGE_URL' ) ) {
117
+ define( 'PS_MAIN_PAGE_URL', esc_url( admin_url( 'options-general.php?page=post-snippets' ) ) );
118
+ }
119
+ class PostSnippets
120
  {
121
+ /** Holds the plugin instance */
122
+ private static $instance = false ;
123
+ /** Define plugin constants */
124
+ const MIN_PHP_VERSION = '5.3.0' ;
125
+ const MIN_WP_VERSION = '3.3' ;
126
+ const SETTINGS = 'post_snippets' ;
127
+ const OPTION_KEY = 'post_snippets_options' ;
128
+ const USER_META_KEY = 'post_snippets' ;
129
+ const FILE = __FILE__ ;
130
+ /**
131
+ * Singleton class
132
+ */
133
+ public static function getInstance()
134
+ {
135
+ if ( !self::$instance ) {
136
+ self::$instance = new self();
137
+ }
138
+ return self::$instance;
139
  }
 
 
 
140
 
141
+ /**
142
+ * Initializes the plugin.
143
+ */
144
+ private function __construct()
145
+ {
146
+ if ( !$this->testHost() ) {
147
+ return;
148
+ }
149
+ load_plugin_textdomain( 'post-snippets', false, dirname( plugin_basename( __FILE__ ) ) . '/lang/' );
150
+ add_action( 'after_setup_theme', array( &$this, 'phpExecState' ) );
151
+ new \PostSnippets\Admin();
152
+ new \PostSnippets\WPEditor();
153
+ new \PostSnippets\Shortcode();
154
  }
155
 
156
+ /**
157
+ * PSR-0 compliant autoloader to load classes as needed.
158
+ *
159
+ * @param string $classname
160
+ *
161
+ * @return void
162
+ */
163
+ public static function autoload( $className )
164
+ {
165
+ if ( __CLASS__ !== mb_substr( $className, 0, strlen( __CLASS__ ) ) ) {
166
+ return;
167
+ }
168
+ $className = ltrim( $className, '\\' );
169
+ $fileName = '';
170
+ $namespace = '';
 
 
 
 
 
 
171
 
172
+ if ( $lastNsPos = strrpos( $className, '\\' ) ) {
173
+ $namespace = substr( $className, 0, $lastNsPos );
174
+ $className = substr( $className, $lastNsPos + 1 );
175
+ $fileName = str_replace( '\\', DIRECTORY_SEPARATOR, $namespace );
176
+ $fileName .= DIRECTORY_SEPARATOR;
177
+ }
178
+
179
+ $fileName .= str_replace( '_', DIRECTORY_SEPARATOR, $className );
180
+ require 'src' . DIRECTORY_SEPARATOR . $fileName . '.php';
181
+ }
182
+
183
+ // -------------------------------------------------------------------------
184
+ // Helpers
185
+ // -------------------------------------------------------------------------
186
+ /**
187
+ * Allow snippets to be retrieved directly from PHP.
188
+ *
189
+ * @since Post Snippets 1.8.9.1
190
+ *
191
+ * @param string $name The name of the snippet to retrieve
192
+ * @param string|array $variables The variables to pass to the snippet,
193
+ * formatted as a query string or an associative array.
194
+ *
195
+ * @return string The Snippet
196
+ */
197
+ public static function getSnippet( $name, $variables = '' )
198
+ {
199
+ $snippets = get_option( self::OPTION_KEY, array() );
200
+ for ( $i = 0 ; $i < count( $snippets ) ; $i++ ) {
201
+
202
+ if ( $snippets[$i]['title'] == $name ) {
203
+ if ( !is_array( $variables ) ) {
204
+ parse_str( htmlspecialchars_decode( $variables ), $variables );
205
+ }
206
+ $snippet = $snippets[$i]['snippet'];
207
+ $var_arr = explode( ",", $snippets[$i]['vars'] );
208
+ if ( !empty($var_arr[0]) ) {
209
+ for ( $j = 0 ; $j < count( $var_arr ) ; $j++ ) {
210
+ $snippet = str_replace( "{" . $var_arr[$j] . "}", $variables[$var_arr[$j]], $snippet );
211
+ }
212
  }
213
+ break;
214
  }
215
+
216
  }
217
+ return do_shortcode( $snippet );
218
+ }
219
 
220
+ // -------------------------------------------------------------------------
221
+ // Environment Checks
222
+ // -------------------------------------------------------------------------
223
+ /**
224
+ * Checks PHP and WordPress versions.
225
+ */
226
+ private function testHost()
227
+ {
228
+ // Check if PHP is too old
229
+
230
+ if ( version_compare( PHP_VERSION, self::MIN_PHP_VERSION, '<' ) ) {
231
+ // Display notice
232
+ add_action( 'admin_notices', array( &$this, 'phpVersionError' ) );
233
+ return false;
234
+ }
235
+
236
+ // Check if WordPress is too old
237
+ global $wp_version ;
238
+
239
+ if ( version_compare( $wp_version, self::MIN_WP_VERSION, '<' ) ) {
240
+ add_action( 'admin_notices', array( &$this, 'wpVersionError' ) );
241
+ return false;
242
+ }
243
+
244
+ return true;
245
  }
 
 
 
 
 
 
 
 
 
 
 
 
246
 
247
+ /**
248
+ * Displays a warning when installed on an old PHP version.
249
+ */
250
+ public function phpVersionError()
251
+ {
252
+ echo '<div class="error"><p><strong>' ;
253
+ printf(
254
+ 'Error: %3$s requires PHP version %1$s or greater.<br/>' . 'Your installed PHP version: %2$s',
255
+ self::MIN_PHP_VERSION,
256
+ PHP_VERSION,
257
+ $this->getPluginName()
258
+ );
259
+ echo '</strong></p></div>' ;
260
  }
261
 
262
+ /**
263
+ * Displays a warning when installed in an old WordPress version.
264
+ */
265
+ public function wpVersionError()
266
+ {
267
+ echo '<div class="error"><p><strong>' ;
268
+ printf( 'Error: %2$s requires WordPress version %1$s or greater.', self::MIN_WP_VERSION, $this->getPluginName() );
269
+ echo '</strong></p></div>' ;
270
+ }
271
 
272
+ /**
273
+ * Get the name of this plugin.
274
+ *
275
+ * @return string The plugin name.
276
+ */
277
+ private function getPluginName()
278
+ {
279
+ $data = get_plugin_data( self::FILE );
280
+ return $data['Name'];
281
  }
282
 
283
+ // -------------------------------------------------------------------------
284
+ // Deprecated methods
285
+ // -------------------------------------------------------------------------
286
+ /**
287
+ * Allow plugins to disable the PHP Code execution feature with a filter.
288
+ * Deprecated: Use the POST_SNIPPETS_DISABLE_PHP global constant to disable
289
+ * PHP instead.
290
+ *
291
+ * @see http://wordpress.org/extend/plugins/post-snippets/faq/
292
+ * @since 2.1
293
+ * @deprecated 2.3
294
+ */
295
+ public function phpExecState()
296
+ {
297
+ $filter = apply_filters( 'post_snippets_php_execution_enabled', true );
298
+
299
+ if ( $filter == false and !defined( 'POST_SNIPPETS_DISABLE_PHP' ) ) {
300
+ _deprecated_function( 'post_snippets_php_execution_enabled', '2.3', 'define(\'POST_SNIPPETS_DISABLE_PHP\', true);' );
301
+ define( 'POST_SNIPPETS_DISABLE_PHP', true );
302
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
303
 
 
 
 
304
  }
305
 
306
  }
307
+ add_action( 'plugins_loaded', array( 'PostSnippets', 'getInstance' ) );
308
+ /**
309
+ * Load all of the necessary class files for the plugin
310
+ */
311
+ spl_autoload_register( 'PostSnippets::autoload' );
312
  }
 
readme.txt CHANGED
@@ -1,10 +1,10 @@
1
  === Post Snippets ===
2
- Contributors: davdebcom, freemius
3
  Tags: custom snippet, custom shortcode, snippet, snippets, shortcode, shortcodes, block, blocks, html
4
  Requires at least: 3.3
5
  Tested up to: 4.9
6
  Requires PHP: 5.3
7
- Stable tag: 3.0.4
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -97,6 +97,15 @@ your clients to be able to use PHP code in a post snippet.
97
 
98
  == Changelog ==
99
 
 
 
 
 
 
 
 
 
 
100
  = Version 3.0.4 - 20 Feb 2018 =
101
 
102
  * Add "Support forum" link to support forum
1
  === Post Snippets ===
2
+ Contributors: davdebcom
3
  Tags: custom snippet, custom shortcode, snippet, snippets, shortcode, shortcodes, block, blocks, html
4
  Requires at least: 3.3
5
  Tested up to: 4.9
6
  Requires PHP: 5.3
7
+ Stable tag: 3.0.5
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
97
 
98
  == Changelog ==
99
 
100
+ = Version 3.0.5 - 13 May 2018 =
101
+
102
+ * Fix conflict with SiteOrigin Page Builder (Editor), increase z-index so Post Snippets Insert box opens on top of the editor
103
+ * Only show submenu when Post Snippets is opened, not on all Settings pages, and remove Support Forum and Contact submenu items
104
+ * Improve stability by updating Post Snippets to string-based menu slug
105
+ * Add instructions and optimize UI for new users/new sites (with slightly pulsating "Add New Snippet" button)
106
+ * Automatically disable Post Snippets if premium version is activated
107
+ * Make 'Post Snippets' header title in plugin translatable
108
+
109
  = Version 3.0.4 - 20 Feb 2018 =
110
 
111
  * Add "Support forum" link to support forum
src/PostSnippets/Admin.php CHANGED
@@ -25,7 +25,7 @@ class Admin
25
  add_action( 'admin_menu', array( &$this, 'menu' ) );
26
  add_action( 'admin_init', array( &$this, 'init' ) );
27
  add_action( 'current_screen', array( &$this, 'addHeaderXss' ) );
28
- add_filter( 'plugin_action_links_' . plugin_basename( PS_PATH . 'post-snippets.php' ), array( $this, 'actionLinks' ) );
29
  // Newsletter sign-up admin notice
30
  add_action( 'admin_notices', array( $this, 'admin_notice_newsletter' ) );
31
  // Get started admin notice
@@ -54,19 +54,19 @@ class Admin
54
 
55
  if ( current_user_can( 'manage_options' ) or isset( $allowed ) ) {
56
  $optionPage = add_options_page(
57
- 'Post Snippets',
58
- 'Post Snippets',
59
  $capability,
60
- \PostSnippets::FILE,
61
  array( &$this, 'optionsPage' )
62
  );
63
  new Help( $optionPage );
64
  } else {
65
  $optionPage = add_options_page(
66
- 'Post Snippets',
67
- 'Post Snippets',
68
  'edit_posts',
69
- \PostSnippets::FILE,
70
  array( &$this, 'overviewPage' )
71
  );
72
  }
@@ -318,11 +318,12 @@ class Admin
318
  <!-- Create a header in the default WordPress \'wrap\' container -->
319
  <div class="wrap">
320
  <div id="icon-plugins" class="icon32"></div>
321
- <h2>Post Snippets</h2>
322
- ' ;
 
323
  // Tabs
324
  $active_tab = ( isset( $_GET['tab'] ) ? $_GET['tab'] : 'snippets' );
325
- $base_url = '?page=' . PS_DIRECTORY . '/post-snippets.php&amp;tab=';
326
  $tabs = array(
327
  'snippets' => __( 'Manage Snippets', 'post-snippets' ),
328
  'options' => __( 'Options', 'post-snippets' ),
25
  add_action( 'admin_menu', array( &$this, 'menu' ) );
26
  add_action( 'admin_init', array( &$this, 'init' ) );
27
  add_action( 'current_screen', array( &$this, 'addHeaderXss' ) );
28
+ add_filter( 'plugin_action_links_' . plugin_basename( PS_MAIN_FILE_PATH ), array( $this, 'actionLinks' ) );
29
  // Newsletter sign-up admin notice
30
  add_action( 'admin_notices', array( $this, 'admin_notice_newsletter' ) );
31
  // Get started admin notice
54
 
55
  if ( current_user_can( 'manage_options' ) or isset( $allowed ) ) {
56
  $optionPage = add_options_page(
57
+ __( 'Post Snippets', 'post-snippets' ),
58
+ __( 'Post Snippets', 'post-snippets' ),
59
  $capability,
60
+ 'post-snippets',
61
  array( &$this, 'optionsPage' )
62
  );
63
  new Help( $optionPage );
64
  } else {
65
  $optionPage = add_options_page(
66
+ __( 'Post Snippets', 'post-snippets' ),
67
+ __( 'Post Snippets', 'post-snippets' ),
68
  'edit_posts',
69
+ 'post-snippets',
70
  array( &$this, 'overviewPage' )
71
  );
72
  }
318
  <!-- Create a header in the default WordPress \'wrap\' container -->
319
  <div class="wrap">
320
  <div id="icon-plugins" class="icon32"></div>
321
+ <h2>' ;
322
+ echo __( 'Post Snippets', 'post-snippets' ) ;
323
+ echo '</h2>' ;
324
  // Tabs
325
  $active_tab = ( isset( $_GET['tab'] ) ? $_GET['tab'] : 'snippets' );
326
+ $base_url = '?page=' . PS_DIRECTORY . '&amp;tab=';
327
  $tabs = array(
328
  'snippets' => __( 'Manage Snippets', 'post-snippets' ),
329
  'options' => __( 'Options', 'post-snippets' ),
src/PostSnippets/Features.php CHANGED
@@ -123,6 +123,10 @@ ob_start();
123
  <?php echo sprintf( __( 'It\'s the professional version of Post Snippets, starting at $%s per year (excl. taxes). You get three votes. The Pro version makes development and support for both versions sustainable, so you get a <strong>higher quality</strong> plugin.', 'post-snippets' ), $price ); ?>
124
  </p>
125
 
 
 
 
 
126
  <p class="ps_features_wrap_intro"><?php _e( 'Other suggestions? Send an email to <a href="mailto:david@postsnippets.com">david@postsnippets.com</a>.', 'post-snippets' ); ?>
127
  </p>
128
 
123
  <?php echo sprintf( __( 'It\'s the professional version of Post Snippets, starting at $%s per year (excl. taxes). You get three votes. The Pro version makes development and support for both versions sustainable, so you get a <strong>higher quality</strong> plugin.', 'post-snippets' ), $price ); ?>
124
  </p>
125
 
126
+ <p class="ps_features_wrap_intro">
127
+ <?php _e( 'By voting you are automatically subscribed to the Post Snippets newsletter, and you can unsubscribe at anytime.', 'post-snippets' ); ?>
128
+ </p>
129
+
130
  <p class="ps_features_wrap_intro"><?php _e( 'Other suggestions? Send an email to <a href="mailto:david@postsnippets.com">david@postsnippets.com</a>.', 'post-snippets' ); ?>
131
  </p>
132
 
views/admin_snippets.php CHANGED
@@ -2,6 +2,7 @@
2
  <?php
3
  wp_nonce_field( 'update_snippets', 'update_snippets_nonce' );
4
  ?>
 
5
  <?php
6
  \PostSnippets\Admin::submit(
7
  'update-snippets',
@@ -22,7 +23,8 @@ wp_nonce_field( 'update_snippets', 'update_snippets_nonce' );
22
  false
23
  );
24
  ?>
25
- <br>
 
26
  <table class="widefat fixed mt-20 post-snippets-table" cellspacing="0">
27
  <thead>
28
  <tr>
@@ -42,6 +44,18 @@ _e( 'Collapse All', 'post-snippets' );
42
  </tr>
43
  </thead>
44
  </table>
 
 
 
 
 
 
 
 
 
 
 
 
45
  <?php
46
  $snippets = get_option( \PostSnippets::OPTION_KEY );
47
 
@@ -176,6 +190,9 @@ if ( !empty($snippets) ) {
176
  <?php
177
  }
178
 
 
 
 
179
  \PostSnippets\Admin::submit(
180
  'update-snippets',
181
  __( 'Update Snippets', 'post-snippets' ),
@@ -194,4 +211,5 @@ if ( !empty($snippets) ) {
194
  'button-secondary',
195
  false
196
  );
 
197
  echo '</form>' ;
2
  <?php
3
  wp_nonce_field( 'update_snippets', 'update_snippets_nonce' );
4
  ?>
5
+ <div class="post-snippets-buttons-top">
6
  <?php
7
  \PostSnippets\Admin::submit(
8
  'update-snippets',
23
  false
24
  );
25
  ?>
26
+ </div>
27
+
28
  <table class="widefat fixed mt-20 post-snippets-table" cellspacing="0">
29
  <thead>
30
  <tr>
44
  </tr>
45
  </thead>
46
  </table>
47
+
48
+ <div class="post-snippets post-snippets-list post-snippets-list-empty" style="display: none;">
49
+ <p>
50
+ <?php
51
+ echo __( 'You\'ve just installed Post Snippets, awesome!', 'post-snippets' ) ;
52
+ ?><br />
53
+ <?php
54
+ echo __( 'Click "Add New Snippet" to create your first snippet or read the documentation at the top right under "Help".', 'post-snippets' ) ;
55
+ ?>
56
+ </p>
57
+ </div>
58
+
59
  <?php
60
  $snippets = get_option( \PostSnippets::OPTION_KEY );
61
 
190
  <?php
191
  }
192
 
193
+ ?>
194
+ <div class="post-snippets-buttons-bottom">
195
+ <?php
196
  \PostSnippets\Admin::submit(
197
  'update-snippets',
198
  __( 'Update Snippets', 'post-snippets' ),
211
  'button-secondary',
212
  false
213
  );
214
+ echo '</div>' ;
215
  echo '</form>' ;
views/jquery_ui_dialog_footer.php CHANGED
@@ -4,20 +4,28 @@
4
  <div id="post-snippets-dialog" title="Post Snippets">
5
  <?php // Init the tabs div ?>
6
  <div id="post-snippets-tabs">
7
- <ul>
8
- <?php
9
- // Create a tab for each available snippet
10
- foreach ($snippets as $key => $snippet) {
11
- ?>
12
- <li><a href="#ps-tabs-<?php echo $key;
13
- ?>"><?php echo $snippet['title'];
14
- ?></a></li>
15
  <?php
16
 
17
- } ?>
18
- </ul>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
19
 
20
- <?php
21
  // Create a panel with form fields for each available snippet
22
  foreach ($snippets as $key => $snippet) {
23
  ?>
4
  <div id="post-snippets-dialog" title="Post Snippets">
5
  <?php // Init the tabs div ?>
6
  <div id="post-snippets-tabs">
7
+
 
 
 
 
 
 
 
8
  <?php
9
 
10
+ if ( empty($snippets)) {
11
+ echo sprintf(__('No snippets found, to create them go to &nbsp;&nbsp; %sPost Snippets &rarr;%s', 'post-snippets'), '<a href="'. admin_url( 'options-general.php?page=post-snippets') .'" class="button-primary">', '</a>');
12
+ } else {
13
+ ?>
14
+ <ul>
15
+ <?php
16
+ // Create a tab for each available snippet
17
+ foreach ( $snippets as $key => $snippet ) {
18
+ ?>
19
+ <li><a href="#ps-tabs-<?php echo $key;
20
+ ?>"><?php echo $snippet['title'];
21
+ ?></a></li>
22
+ <?php
23
+ }
24
+ ?>
25
+ </ul>
26
+ <?php
27
+ }
28
 
 
29
  // Create a panel with form fields for each available snippet
30
  foreach ($snippets as $key => $snippet) {
31
  ?>