Cryout Serious Theme Settings - Version 0.5.13

Version Description

  • Updated for compatibility with the changes in Nirvana 1.6.0
  • Bumped supported WordPress version to 5.8
Download this release

Release Info

Developer Cryout Creations
Plugin Icon wp plugin Cryout Serious Theme Settings
Version 0.5.13
Comparing to
See all releases

Code changes from version 0.5.12 to 0.5.13

Files changed (3) hide show
  1. cryout-theme-settings.php +2 -2
  2. inc/nirvana.php +304 -0
  3. readme.txt +8 -4
cryout-theme-settings.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: Cryout Serious Theme Settings
4
  Plugin URI: https://www.cryoutcreations.eu/wordpress-plugins/serious-theme-settings
5
  Description: This plugin is designed to enable the themes' settings page functionality. It will work with the following themes: Nirvana, Parabola, Tempera or Mantra.
6
- Version: 0.5.12
7
  Author: Cryout Creations
8
  Author URI: https://www.cryoutcreations.eu
9
  License: GPLv3
@@ -14,7 +14,7 @@
14
  if ( !defined( 'ABSPATH' ) ) exit;
15
 
16
  class Cryout_Theme_Settings {
17
- public $version = "0.5.12";
18
  public $settings = array();
19
 
20
  private $status = 0; // 0 = inactive, 1 = active, 2 = good theme, wrong version, 3 = wrong theme, 4 = compatibility for wp4.4, 5 = theme requires update
3
  Plugin Name: Cryout Serious Theme Settings
4
  Plugin URI: https://www.cryoutcreations.eu/wordpress-plugins/serious-theme-settings
5
  Description: This plugin is designed to enable the themes' settings page functionality. It will work with the following themes: Nirvana, Parabola, Tempera or Mantra.
6
+ Version: 0.5.13
7
  Author: Cryout Creations
8
  Author URI: https://www.cryoutcreations.eu
9
  License: GPLv3
14
  if ( !defined( 'ABSPATH' ) ) exit;
15
 
16
  class Cryout_Theme_Settings {
17
+ public $version = "0.5.13";
18
  public $settings = array();
19
 
20
  private $status = 0; // 0 = inactive, 1 = active, 2 = good theme, wrong version, 3 = wrong theme, 4 = compatibility for wp4.4, 5 = theme requires update
inc/nirvana.php CHANGED
@@ -28,3 +28,307 @@ function nirvana_extra() {
28
  $url = untrailingslashit( plugin_dir_url( dirname(__FILE__) ) ) . '/media';
29
  include_once( plugin_dir_path( __FILE__ ) . 'extra.php' );
30
  } // nirvana_extra()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
28
  $url = untrailingslashit( plugin_dir_url( dirname(__FILE__) ) ) . '/media';
29
  include_once( plugin_dir_path( __FILE__ ) . 'extra.php' );
30
  } // nirvana_extra()
31
+
32
+ if ( version_compare( $this->current_theme['version'], '1.6.0', '>=' ) ) {
33
+ // all the functionality below is conditioned to running Nirvana v1.6.0 or newer and is not needed in older versions
34
+
35
+ /**
36
+ * Export Nirvana settings to file
37
+ */
38
+
39
+ function nirvana_export_options(){
40
+
41
+ if ( ! isset( $_POST['nirvana_export'] ) ) return;
42
+
43
+ if (ob_get_contents()) ob_clean();
44
+
45
+ /* Check authorisation */
46
+ $authorised = true;
47
+ // Check nonce
48
+ if ( ! wp_verify_nonce( $_POST['nirvana-export'], 'nirvana-export' ) ) {
49
+ $authorised = false;
50
+ }
51
+ // Check permissions
52
+ if ( ! current_user_can( 'edit_theme_options' ) ){
53
+ $authorised = false;
54
+ }
55
+
56
+ if ( $authorised) {
57
+ global $nirvanas;
58
+ date_default_timezone_set('UTC');
59
+ $name = 'nirvanasettings-'.preg_replace("/[^a-z0-9-_]/i",'',str_replace("http://","",get_option('siteurl'))).'-'.date('Ymd-His').'.txt';
60
+
61
+ $data = $nirvanas;
62
+ $data = json_encode( $data );
63
+ $size = strlen( $data );
64
+
65
+ header( 'Content-Type: text/plain' );
66
+ header( 'Content-Disposition: attachment; filename="'.$name.'"' );
67
+ header( "Content-Transfer-Encoding: binary" );
68
+ header( 'Accept-Ranges: bytes' );
69
+
70
+ /* The three lines below basically make the download non-cacheable */
71
+ header( "Cache-control: private" );
72
+ header( 'Pragma: private' );
73
+ header( "Expires: Mon, 26 Jul 1997 05:00:00 GMT" );
74
+
75
+ header( "Content-Length: " . $size);
76
+ print( $data );
77
+ }
78
+ die();
79
+ } // nirvana_export_options()
80
+ add_action( 'admin_init', 'nirvana_export_options' );
81
+
82
+ /**
83
+ * This file manages the theme settings uploading and import operations.
84
+ * Uses the theme page to create a new form for uplaoding the settings
85
+ * Uses WP_Filesystem
86
+ */
87
+ function nirvana_import_form(){
88
+
89
+ $bytes = apply_filters( 'import_upload_size_limit', wp_max_upload_size() );
90
+ $size = size_format( $bytes );
91
+ $upload_dir = wp_upload_dir();
92
+ if ( ! empty( $upload_dir['error'] ) ) :
93
+ ?><div class="error"><p><?php _e('Before you can upload your import file, you will need to fix the following error:', 'nirvana'); ?></p>
94
+ <p><strong><?php echo $upload_dir['error']; ?></strong></p></div><?php
95
+ else :
96
+ ?>
97
+
98
+ <div class="wrap cryout-admin">
99
+ <div style="width:400px;display:block;margin-left:30px;">
100
+ <div id="icon-tools" class="icon32"><br></div>
101
+ <h2><?php echo __( 'Import Nirvana Settings', 'nirvana' );?></h2>
102
+ <form enctype="multipart/form-data" id="import-upload-form" method="post" action="">
103
+ <p><?php _e('Only files obtained from Nirvana\'s export process are supported.', 'nirvana'); ?></p>
104
+ <p>
105
+ <label for="upload"><strong><?php printf( __('Select an existing theme settings file: %s', 'nirvana'), '(nirvana-settings.txt)' ) ?> </strong><i></i></label>
106
+ <input type="file" id="upload" name="import" size="25" />
107
+ <span style="font-size:10px;">(<?php printf( __( 'Maximum size: %s', 'nirvana' ), $size ); ?> )</span>
108
+ <input type="hidden" name="action" value="save" />
109
+ <input type="hidden" name="max_file_size" value="<?php echo $bytes; ?>" />
110
+ <?php wp_nonce_field('nirvana-import', 'nirvana-import'); ?>
111
+ <input type="hidden" name="nirvana_import_confirmed" value="true" />
112
+ </p>
113
+ <input type="submit" class="button" value="<?php _e('And import!', 'nirvana'); ?>" />
114
+ </form>
115
+ </div>
116
+ </div> <!-- end wrap -->
117
+ <?php
118
+ endif;
119
+ } // Closes the nirvana_import_form() function definition
120
+
121
+
122
+ /**
123
+ * This actual import of the options from the file to the settings array.
124
+ */
125
+ function nirvana_import_file() {
126
+ global $nirvanas;
127
+
128
+ /* Check authorisation */
129
+ $authorised = true;
130
+ // Check nonce
131
+ if (!wp_verify_nonce($_POST['nirvana-import'], 'nirvana-import')) {$authorised = false;}
132
+ // Check permissions
133
+ if (!current_user_can('edit_theme_options')){ $authorised = false; }
134
+
135
+ // If the user is authorised, import the theme's options to the database
136
+ if ($authorised) {?>
137
+ <?php
138
+ // make sure there is an import file uploaded
139
+ if ( (isset($_FILES["import"]["size"]) && ($_FILES["import"]["size"] > 0) ) ) {
140
+
141
+ $form_fields = array('import');
142
+ $method = '';
143
+
144
+ $url = wp_nonce_url('themes.php?page=nirvana-page', 'nirvana-import');
145
+
146
+ // Get file writing credentials
147
+ if (false === ($creds = request_filesystem_credentials($url, $method, false, false, $form_fields) ) ) {
148
+ return true;
149
+ }
150
+
151
+ if ( ! WP_Filesystem($creds) ) {
152
+ // our credentials were no good, ask the user for them again
153
+ request_filesystem_credentials($url, $method, true, false, $form_fields);
154
+ return true;
155
+ }
156
+
157
+ // Write the file if credentials are good
158
+ $upload_dir = wp_upload_dir();
159
+ $filename = trailingslashit($upload_dir['path']).'nirvanas.txt';
160
+
161
+ // by this point, the $wp_filesystem global should be working, so let's use it to create a file
162
+ global $wp_filesystem;
163
+ if ( ! $wp_filesystem->move($_FILES['import']['tmp_name'], $filename, true) ) {
164
+ echo 'Error saving file!';
165
+ return;
166
+ }
167
+
168
+ $file = $_FILES['import'];
169
+
170
+ if ($file['type'] == 'text/plain') {
171
+ $data = $wp_filesystem->get_contents($filename);
172
+ // try to read the file
173
+ if ($data !== FALSE){
174
+ $settings = json_decode($data, true);
175
+ // try to read the settings array
176
+ if (isset($settings['nirvana_db'])){ ?>
177
+ <div class="wrap cryout-admin">
178
+ <div id="icon-tools" class="icon32"><br></div>
179
+ <h2><?php echo __( 'Import Nirvana Theme Options', 'nirvana' );?></h2> <?php
180
+ $settings = array_merge($nirvanas, $settings);
181
+ update_option('nirvana_settings', $settings);
182
+ echo '<div class="updated fade"><p>'. __('Great! The options have been imported!', 'nirvana').'<br />';
183
+ printf( '<a href="%s">%s<a></p></div>', admin_url( 'themes.php?page=nirvana-page' ), __('Go back to the settings page and check them out!', 'nirvana') );
184
+ }
185
+ else { // else: try to read the settings array
186
+ echo '<div class="error"><p><strong>'.__('Oops, there\'s a small problem.', 'nirvana').'</strong><br />';
187
+ echo __('The uploaded file does not contain valid Nirvana settings. Make sure the file is exported from Nirvana.', 'nirvana').'</p></div>';
188
+ nirvana_import_form();
189
+ }
190
+ }
191
+ else { // else: try to read the file
192
+ echo '<div class="error"><p><strong>'.__('Oops, there\'s a small problem.', 'nirvana').'</strong><br />';
193
+ echo __('The uploaded file could not be read.', 'nirvana').'</p></div>';
194
+ nirvana_import_form();
195
+ }
196
+ }
197
+ else { // else: make sure the file uploaded was a plain text file
198
+ echo '<div class="error"><p><strong>'.__('Oops, there\'s a small problem.', 'nirvana').'</strong><br />';
199
+ echo __('The uploaded file is not supported. Make sure the file was exported from Nirvana and that it is a text file.', 'nirvana').'</p></div>';
200
+ nirvana_import_form();
201
+ }
202
+
203
+ // Delete the file after we're done
204
+ $wp_filesystem->delete($filename);
205
+
206
+ }
207
+ else { // else: make sure there is an import file uploaded
208
+ echo '<div class="error"><p>'.__( 'Oops! The file is empty or there was no file. This error could also be caused by uploads being disabled in your php.ini or by post_max_size being defined as smaller than upload_max_filesize in php.ini.', 'nirvana' ).'</p></div>';
209
+ nirvana_import_form();
210
+ }
211
+ echo '</div> <!-- end wrap -->';
212
+ }
213
+ else {
214
+ wp_die(__('ERROR: You are not authorised to perform that operation', 'nirvana'));
215
+ }
216
+ } // Closes the nirvana_import_file() function definition
217
+
218
+
219
+
220
+ function nirvana_presets(){
221
+ ?>
222
+ <script type="text/javascript">
223
+ var scheme_confirmation = '<?php echo esc_html__('Are you sure you want to load a new color scheme? \nAll current saved settings under Text and Color Settings will be lost.','nirvana'); ?>';
224
+ </script>
225
+ <div class="wrap cryout-admin">
226
+ <div id="admin_header"><img src="<?php echo get_template_directory_uri() . '/admin/images/colorschemes-logo.png' ?>" /> </div>
227
+ <div style="display:block;margin-left:30px;clear:both;float:none;">
228
+ <p><em><?php echo _e("Select one of the preset color schemes and press the Load button.<br> <b> CAUTION! </b> When loading a color scheme, the Nirvana theme settings under Text and Color Settings will be overriden. All other settings will remain intact.<br> <u>SUGGESTION:</u> It's always better to export your current theme settings before loading a color scheme." , "nirvana"); ?></em></p>
229
+ <br>
230
+ <form name="nirvana_form" action="options.php" method="post" enctype="multipart/form-data">
231
+
232
+ <?php
233
+ settings_fields('nirvana_settings');
234
+
235
+ global $nirvanas;
236
+ global $nirvana_colorschemes_array;
237
+
238
+ foreach($nirvana_colorschemes_array as $key=>$item) {
239
+ $id = preg_replace('/[^a-z0-9]/i', '',$key);
240
+ $checkedClass = ($nirvanas['nirvana_colorschemes']==$item) ? ' checkedClass' : '';
241
+ /* printf( "<label id='%1$s' for='sel_%2$s' class='images presets %3$s'>
242
+ <input %4$s value='%5$s' id='sel_%2$s' onClick=\"changeBorder('%1$s','images');\" name='nirvana_settings[nirvana_colorschemes]' type='radio' />
243
+ <img class='%2$s' src='%6$s'/> <p>%5$s</p>
244
+ </label>\n",
245
+ $id,
246
+ strtolower( $id ),
247
+ $checkedClass,
248
+ checked($nirvanas['nirvana_colorschemes'], $item, false),
249
+ $key,
250
+ sprintf( '%1%s/admin/images/schemes/%2$s.png', esc_url( get_template_directory_uri() ), $key )
251
+ ); */
252
+ echo " <label id='$id' for='$id$id' class='images presets $checkedClass'><input ";
253
+ checked($nirvanas['nirvana_colorschemes'],$item);
254
+ echo " value='$key' id='$id$id' onClick=\"changeBorder('$id','images');\" name='nirvana_settings[nirvana_colorschemes]' type='radio' /><img class='$id' src='".get_template_directory_uri()."/admin/images/schemes/{$key}.png'/><p>{$key}</p></label>";
255
+ }
256
+ ?>
257
+
258
+ <div id="submitDiv" style="width:400px;display:block;margin:0 auto;">
259
+ <br>
260
+ <input type="hidden" value="true" name="nirvana_presets_loaded" />
261
+ <input class="button" name="nirvana_settings[nirvana_schemessubmit]" type="submit" id="load-color-scheme" style="width:400px;height:40px;display:block;text-align:center;" value="<?php _e('Load Color Scheme','nirvana'); ?>" />
262
+ </div>
263
+ </form>
264
+ </div>
265
+ </div> <!-- end wrap -->
266
+ <br>
267
+ <?php
268
+ } // nirvana_presets()
269
+
270
+
271
+ // Truncate function for use in the Admin RSS feed
272
+ function nirvana_truncate_words($string,$words=20, $ellipsis=' ...') {
273
+ $new = preg_replace('/((\w+\W+\'*){'.($words-1).'}(\w+))(.*)/', '${1}', $string);
274
+ return $new.$ellipsis;
275
+ }
276
+
277
+ function nirvana_righty_below() { ?>
278
+
279
+ <div id="nirvana-export" class="postbox export non-essential-option" style="overflow:hidden;">
280
+ <h3 class="hndle"><?php _e( 'Import/Export Settings', 'nirvana' ); ?></h3>
281
+ <div class="panel-wrap inside">
282
+ <form action="" method="post">
283
+ <?php wp_nonce_field('nirvana-export', 'nirvana-export'); ?>
284
+ <input type="hidden" name="nirvana_export" value="true" />
285
+ <input type="submit" class="button" value="<?php _e('Export Theme options', 'nirvana'); ?>" />
286
+ <p class="imex-text"><?php _e("It's that easy: a mouse click away - the ability to export your Nirvana settings and save them on your computer. Feeling safer? You should!","nirvana"); ?></p>
287
+ </form>
288
+ <br />
289
+ <form action="" method="post">
290
+ <input type="hidden" name="nirvana_import" value="true" />
291
+ <input type="submit" class="button" value="<?php _e('Import Theme options', 'nirvana'); ?>" />
292
+ <p class="imex-text"><?php _e("Without the import, the export would just be a fool's exercise. Make sure you have the exported file ready and see you after the mouse click.","nirvana"); ?></p>
293
+ </form>
294
+ <br />
295
+ <form action="" method="post">
296
+ <input type="hidden" name="nirvana_presets" value="true" />
297
+ <input type="submit" class="button" id="presets_button" value="<?php _e('Color Schemes', 'nirvana'); ?>" />
298
+ <p class="imex-text"><?php _e("A collection of preset color schemes to use as the starting point for your site. Just load one up and see your blog in a different light.","nirvana"); ?></p>
299
+ </form>
300
+ </div><!-- inside -->
301
+ </div><!-- export -->
302
+
303
+ <div id="nirvana-news" class="postbox news" >
304
+ <h3 class="hndle"><?php _e( 'Nirvana Latest News', 'nirvana' ); ?></h3>
305
+ <div class="panel-wrap inside" style="height:200px;overflow:auto;">
306
+ <?php
307
+ $news_feed = fetch_feed( array( 'http://www.cryoutcreations.eu/cat/wordpress-themes/nirvana/feed/') );
308
+ $maxitems = 0;
309
+ if ( ! is_wp_error( $news_feed ) ) {
310
+ $maxitems = $news_feed->get_item_quantity( 10 );
311
+ $news_items = $news_feed->get_items( 0, $maxitems );
312
+ }
313
+ ?>
314
+ <ul class="news-list">
315
+ <?php if ( $maxitems == 0 ) : echo '<li>' . __( 'No news items.', 'parabola' ) . '</li>'; else :
316
+ foreach( $news_items as $news_item ) : ?>
317
+ <li>
318
+ <a class="news-header" href='<?php echo esc_url( $news_item->get_permalink() ); ?>'><?php echo esc_html( $news_item->get_title() ); ?></a><br />
319
+ <span class="news-item-date"><?php _e('Posted on','parabola'); echo $news_item->get_date(' j F Y, H:i'); ?></span>
320
+
321
+ <br><a class="news-read" href='<?php echo esc_url( $news_item->get_permalink() ); ?>'>Read the full post &raquo;</a><br />
322
+ </li>
323
+ <?php endforeach; endif; ?>
324
+ </ul>
325
+ </div><!-- inside -->
326
+ </div><!-- news -->
327
+
328
+ <?php
329
+ } // nirvana_righty_below()
330
+ add_action( 'nirvana_after_righty', 'nirvana_righty_below' );
331
+
332
+ } // endif version_compare()
333
+
334
+ // FIN
readme.txt CHANGED
@@ -3,8 +3,8 @@ Contributors: Cryout Creations
3
  Donate link: https://www.cryoutcreations.eu/donate/
4
  Tags: theme, admin
5
  Requires at least: 4.5
6
- Tested up to: 5.7
7
- Stable tag: 0.5.12
8
  License: GPLv3
9
  License URI: http://www.gnu.org/licenses/gpl.html
10
 
@@ -22,14 +22,14 @@ The plugin is intended to be used with the following theme releases regardless o
22
  * Parabola version 1.6 and newer
23
  * Mantra version 2.5 and newer
24
 
25
- Additionally, it is needed to correct an incompatibility between WordPress 4.4 and newer and the following theme versions:
26
 
27
  * Tempera versions 0.9 to 1.3.3
28
  * Parabola versions 0.9 to 1.5.1
29
  * Mantra versions 2.0 to 2.4.1.1
30
  * No Nirvana versions are supported in compatibility mode
31
 
32
- This plugin will do nothing if you do not use any of the listed themes.
33
 
34
  == Installation ==
35
 
@@ -50,6 +50,10 @@ This plugin will do nothing if you do not use any of the listed themes.
50
 
51
  == Changelog ==
52
 
 
 
 
 
53
  = 0.5.12 =
54
  * Updated for compatibility with the changes in Parabola 2.4.0
55
  * Improved version detection for better compatibility with customized themes
3
  Donate link: https://www.cryoutcreations.eu/donate/
4
  Tags: theme, admin
5
  Requires at least: 4.5
6
+ Tested up to: 5.8.0
7
+ Stable tag: 0.5.13
8
  License: GPLv3
9
  License URI: http://www.gnu.org/licenses/gpl.html
10
 
22
  * Parabola version 1.6 and newer
23
  * Mantra version 2.5 and newer
24
 
25
+ Additionally, it was needed to correct an incompatibility between a change introduced by WordPress 4.4 and the following theme versions:
26
 
27
  * Tempera versions 0.9 to 1.3.3
28
  * Parabola versions 0.9 to 1.5.1
29
  * Mantra versions 2.0 to 2.4.1.1
30
  * No Nirvana versions are supported in compatibility mode
31
 
32
+ This plugin has no use and will do nothing if you do not use any of the listed themes.
33
 
34
  == Installation ==
35
 
50
 
51
  == Changelog ==
52
 
53
+ = 0.5.13 =
54
+ * Updated for compatibility with the changes in Nirvana 1.6.0
55
+ * Bumped supported WordPress version to 5.8
56
+
57
  = 0.5.12 =
58
  * Updated for compatibility with the changes in Parabola 2.4.0
59
  * Improved version detection for better compatibility with customized themes