diff --git a/changelog.txt b/changelog.txt index ea28df2..9a2de12 100644 --- a/changelog.txt +++ b/changelog.txt @@ -2,6 +2,9 @@ == Changelog == += 1.0.8 = +* Fix minor bugs + = 1.0.7.7 = * Fix: PHP error : Trying to get property of non-object diff --git a/external/dash-notice b/external/dash-notice deleted file mode 160000 index bda258b..0000000 --- a/external/dash-notice +++ /dev/null @@ -1 +0,0 @@ -Subproject commit bda258bc46cbf9646bc8220c9b9a63856f0112e6 diff --git a/tips.php b/tips.php index 1096d67..e4ea460 100644 --- a/tips.php +++ b/tips.php @@ -1,10 +1,10 @@ ID, 'show_tips', 'no'); - wp_safe_redirect(wp_get_referer()); + + update_user_meta( $current_user->ID, 'show_tips', 'no' ); + wp_safe_redirect( wp_get_referer() ); exit(); } function tips_enqueue_scripts() { - wp_enqueue_script('jquery'); + wp_enqueue_script( 'jquery' ); } function tips_make_current() { - global $wpdb, $tips_current_version; - if (get_site_option( "tips_version" ) == '') { - add_site_option( 'tips_version', '0.0.0' ); - } - tips_global_install(); - if (get_site_option( "tips_version" ) == $tips_current_version) { - // do nothing - } else { - //update to current version - // update_site_option( "tips_installed", "no" ); - update_site_option( "tips_version", $tips_current_version ); - } - //--------------------------------------------------// - if (get_option( "tips_version" ) == '') { - add_option( 'tips_version', '0.0.0' ); - } - - if (get_option( "tips_version" ) == $tips_current_version) { - // do nothing - } else { - //update to current version - update_option( "tips_version", $tips_current_version ); - tips_blog_install(); - } -} + global $tips_current_version; -function tips_blog_install() { - global $wpdb, $tips_current_version; + if ( get_site_option( 'tips_version' ) === $tips_current_version ) { + // do nothing + } else { + tips_global_install(); + //update to current version + + } } + + function tips_global_init() { - if (preg_match('/mu\-plugin/', PLUGINDIR) > 0) { - load_muplugin_textdomain(TIPS_LANG_DOMAIN, false, dirname(plugin_basename(__FILE__)).'/languages'); + if ( preg_match( '/mu\-plugin/', PLUGINDIR ) > 0 ) { + load_muplugin_textdomain( 'tips', false, dirname( plugin_basename( __FILE__ ) ) . '/languages' ); } else { - load_plugin_textdomain(TIPS_LANG_DOMAIN, false, dirname(plugin_basename(__FILE__)).'/languages'); + load_plugin_textdomain( 'tips', false, dirname( plugin_basename( __FILE__ ) ) . '/languages' ); } } +/** + * + * @global type $wpdb + * @global string $tips_current_version + * + * @version 2.0 + */ function tips_global_install() { global $wpdb, $tips_current_version; - + // Get the correct character collate - if ( ! empty($wpdb->charset) ) + if ( ! empty( $wpdb->charset ) ) { $charset_collate = "DEFAULT CHARACTER SET $wpdb->charset"; - if ( ! empty($wpdb->collate) ) + } + if ( ! empty( $wpdb->collate ) ) { $charset_collate .= " COLLATE $wpdb->collate"; - - if (get_site_option( "tips_installed" ) == '') { + } + + if ( ! ( get_site_option( 'tips_installed' ) ) ) { add_site_option( 'tips_installed', 'no' ); } - - if (get_site_option( "tips_installed" ) == "yes") { - if ( version_compare("1.0.4", get_site_option( "tips_version" )) >= 0) { - $tips_table1 = "ALTER TABLE `" . $wpdb->base_prefix . "tips` ADD `tip_status` INT( 1 ) NOT NULL DEFAULT '1' AFTER `tip_added` ;"; - $wpdb->query( $tips_table1 ); + + if ( 'yes' === get_site_option( 'tips_installed' ) ) { + if ( version_compare( '1.0.4', get_site_option( 'tips_version' ) ) >= 0 ) { + $tips_table1 = 'ALTER TABLE `' . $wpdb->base_prefix . "tips` ADD `tip_status` INT( 1 ) NOT NULL DEFAULT '1' AFTER `tip_added` ;"; + $wpdb->query( $tips_table1 ); } } else { - $tips_table1 = "CREATE TABLE IF NOT EXISTS `" . $wpdb->base_prefix . "tips` ( + $tips_table1 = 'CREATE TABLE IF NOT EXISTS `' . $wpdb->base_prefix . "tips` ( `tip_ID` bigint(20) unsigned NOT NULL auto_increment, `tip_site_ID` int(20) NOT NULL default '0', `tip_content` TEXT CHARACTER SET utf8, `tip_added` varchar(255), `tip_status` int(1) NOT NULL default '1', PRIMARY KEY (`tip_ID`) -) ENGINE=MyISAM {$charset_collate};"; - +) {$charset_collate};"; $wpdb->query( $tips_table1 ); - update_site_option( "tips_installed", "yes" ); + update_site_option( 'tips_installed', 'yes' ); + update_site_option( 'tips_version', $tips_current_version ); } } +/** + * + * @global type $tips_menu_slug + * @version 2.0 + */ function tips_plug_pages() { global $tips_menu_slug; - - if (is_super_admin()) - add_submenu_page( $tips_menu_slug, __('Tips', TIPS_LANG_DOMAIN), __('Tips', TIPS_LANG_DOMAIN), 'manage_options', 'manage-tips', 'tips_manage_output' ); + + if ( is_super_admin() ) { + add_submenu_page( $tips_menu_slug, __( 'Tips', 'tips' ), __( 'Tips', 'tips' ), 'manage_options', 'manage-tips', 'tips_manage_output' ); + } } +/** + * + * @global type $user_id + * + * @version 2.0 + */ function tips_profile_option_update() { global $user_id; - if ( $_POST['show_tips'] != '' ) { - update_user_meta($user_id, 'show_tips', $_POST['show_tips']); + if ( '' !== $_POST['show_tips'] ) { + update_user_meta( $user_id, 'show_tips', $_POST['show_tips'] ); } } @@ -172,25 +178,26 @@ function tips_profile_option_update() { //------------------------------------------------------------------------// function tips_output() { - global $wpdb, $current_site, $tmp_tips_prefix, $tmp_tips_suffix, $current_user; - + global $wpdb, $tmp_tips_prefix, $tmp_tips_suffix, $current_user; + //hide if turned off - $show_tips = get_user_meta($current_user->ID,'show_tips', true); - if ( 'no' == $show_tips ) return; - + $show_tips = get_user_meta( $current_user->ID, 'show_tips', true ); + if ( 'no' === $show_tips ) { + return; + } - $dismissed_tips = isset($_COOKIE['tips_dismissed'])?maybe_unserialize(stripslashes($_COOKIE['tips_dismissed'])):array(); - if (count($dismissed_tips) > 0) { - $dismissed_tips_sql = "AND tip_ID NOT IN(" . join(',', $dismissed_tips) . ")"; + $dismissed_tips = isset( $_COOKIE['tips_dismissed'] ) ? maybe_unserialize( stripslashes( $_COOKIE['tips_dismissed'] ) ) : array(); + if ( 0 < count( $dismissed_tips ) ) { + $dismissed_tips_sql = 'AND tip_ID NOT IN(' . join( ',', $dismissed_tips ) . ')'; } else { - $dismissed_tips_sql = ""; + $dismissed_tips_sql = ''; } - $tmp_tips_count = $wpdb->get_var("SELECT COUNT(*) FROM " . $wpdb->base_prefix . "tips WHERE tip_site_ID = '" . $wpdb->siteid . "' AND tip_status = 1 {$dismissed_tips_sql} "); - if ($tmp_tips_count > 0){ - $tmp_tip = $wpdb->get_row("SELECT tip_ID, tip_content FROM " . $wpdb->base_prefix . "tips WHERE tip_site_ID = '" . $wpdb->siteid . "' AND tip_status = 1 {$dismissed_tips_sql} ORDER BY RAND() LIMIT 1"); + $tmp_tips_count = $wpdb->get_var( 'SELECT COUNT(*) FROM ' . $wpdb->base_prefix . "tips WHERE tip_site_ID = '" . $wpdb->siteid . "' AND tip_status = 1 {$dismissed_tips_sql} " ); + if ( $tmp_tips_count > 0 ) { + $tmp_tip = $wpdb->get_row( 'SELECT tip_ID, tip_content FROM ' . $wpdb->base_prefix . "tips WHERE tip_site_ID = '" . $wpdb->siteid . "' AND tip_status = 1 {$dismissed_tips_sql} ORDER BY RAND() LIMIT 1" ); $tmp_tip_content = $tmp_tips_prefix . $tmp_tip->tip_content . $tmp_tips_suffix; ?> -
+