Skip to content

Commit

Permalink
* Fix bug with setting of default options.
Browse files Browse the repository at this point in the history
 * Fix bug with plugin menu.
 * Update plugin menu css.
  • Loading branch information
azurecurve committed Apr 5, 2020
1 parent fa42627 commit e8de9cf
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 23 deletions.
42 changes: 23 additions & 19 deletions azrcrv-timelines.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

// include plugin menu
require_once(dirname( __FILE__).'/pluginmenu/menu.php');
register_activation_hook(__FILE__, 'azrcrv_create_plugin_menu_t');
add_action('admin_init', 'azrcrv_create_plugin_menu_t');

// include update client
require_once(dirname(__FILE__).'/libraries/updateclient/UpdateClient.class.php');
Expand All @@ -36,9 +36,7 @@
*
*/
// add actions
register_activation_hook(__FILE__, 'azrcrv_t_set_default_options');

// add actions
add_action('admin_init', 'azrcrv_t_set_default_options');
add_action('admin_menu', 'azrcrv_t_create_admin_menu');
add_action('admin_post_azrcrv_t_save_options', 'azrcrv_t_save_options');
add_action('wp_enqueue_scripts', 'azrcrv_t_load_css');
Expand Down Expand Up @@ -132,6 +130,7 @@ function azrcrv_t_set_default_options($networkwide){
'date' => 'd/m/Y',
'dateleftalignment' => '-150px',
'orderby' => 'Ascending',
'updated' => strtotime('2020-04-04'),
);

// set defaults for multi-site
Expand Down Expand Up @@ -172,23 +171,23 @@ function azrcrv_t_set_default_options($networkwide){
function azrcrv_t_update_options($option_name, $new_options, $is_network_site, $old_option_name){
if ($is_network_site == true){
if (get_site_option($option_name) === false){
if (get_site_option($old_option_name) === false){
add_site_option($option_name, $new_options);
}else{
add_site_option($option_name, azrcrv_t_update_default_options($new_options, get_site_option($old_option_name)));
}
add_site_option($option_name, $new_options);
}else{
update_site_option($option_name, azrcrv_t_update_default_options($new_options, get_site_option($option_name)));
$options = get_site_option($option_name);
if (!isset($options['updated']) OR $options['updated'] < $new_options['updated'] ){
$options['updated'] = $new_options['updated'];
update_site_option($option_name, azrcrv_t_update_default_options($options, $new_options));
}
}
}else{
if (get_option($option_name) === false){
if (get_option($old_option_name) === false){
add_option($option_name, $new_options);
}else{
add_option($option_name, azrcrv_t_update_default_options($new_options, get_option($old_option_name)));
}
add_option($option_name, $new_options);
}else{
update_option($option_name, azrcrv_t_update_default_options($new_options, get_option($option_name)));
$options = get_option($option_name);
if (!isset($options['updated']) OR $options['updated'] < $new_options['updated'] ){
$options['updated'] = $new_options['updated'];
update_option($option_name, azrcrv_t_update_default_options($options, $new_options));
}
}
}
}
Expand All @@ -205,10 +204,10 @@ function azrcrv_t_update_default_options( &$default_options, $current_options )
$current_options = (array) $current_options;
$updated_options = $current_options;
foreach ($default_options as $key => &$value) {
if (is_array( $value) && isset( $updated_options[$key ])){
if (is_array( $value) && isset( $updated_options[$key])){
$updated_options[$key] = azrcrv_t_update_default_options($value, $updated_options[$key]);
} else {
$updated_options[$key] = $value;
$updated_options[$key] = $value;
}
}
return $updated_options;
Expand Down Expand Up @@ -304,7 +303,12 @@ function azrcrv_t_display_options(){
foreach ($timelines as $timeline){
//echo '|'.$timeline->term_id.'|';
echo "<option value='".$timeline->term_id."' ";
echo selected($options["timeline"], $timeline->term_id).">";
if (isset($options["timeline"])){
$timeline_option = $options["timeline"];
}else{
$timeline_option= '';
}
echo selected($timeline_option, $timeline->term_id).">";
echo esc_html($timeline->name);
echo "</option>";
}
Expand Down
5 changes: 3 additions & 2 deletions pluginmenu/css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@ a.azrcrv-plugin-index{
color: #fff;
background: #007FFF;
width: 220px;
height: 125px;
line-height: 125px;
height: 75px;
line-height: 75px;
text-decoration: none;
font-weight: 700;
border-radius: 5px;
}
a.azrcrv-plugin-index:hover{
text-decoration: underline;
Expand Down
9 changes: 7 additions & 2 deletions readme.txt
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
=== Timelines ===

Description: Create timelines showing the sequence of events and place in any post or page using a shortcode.
Version: 1.1.4
Version: 1.1.5
Tags: timeline, timelines, custom post type
Author: azurecurve
Author URI: https://development.azurecurve.co.uk/
Plugin URI: https://development.azurecurve.co.uk/classicpress-plugins/timelines/
Download link: https://github.com/azurecurve/azrcrv-timelines/releases/download/v1.1.4/azrcrv-timelines.zip
Download link: https://github.com/azurecurve/azrcrv-timelines/releases/download/v1.1.5/azrcrv-timelines.zip
Donate link: https://development.azurecurve.co.uk/support-development/
Requires PHP: 5.6
Requires: 1.0.0
Expand Down Expand Up @@ -51,6 +51,11 @@ This plugin is developed for ClassicPress, but will likely work on WordPress.

# Changelog

### [Version 1.1.5](https://github.com/azurecurve/azrcrv-timelines/releases/tag/v1.1.5)
* Fix bug with setting of default options.
* Fix bug with plugin menu.
* Update plugin menu css.

### [Version 1.1.4](https://github.com/azurecurve/azrcrv-timelines/releases/tag/v1.1.4)
* Rewrite default option creation function to resolve several bugs.
* Upgrade azurecurve plugin to store available plugins in options.
Expand Down

0 comments on commit e8de9cf

Please sign in to comment.