From 28911b8370cc33c8e18f663c12dce56877a3fa9f Mon Sep 17 00:00:00 2001 From: Lena Stergatou Date: Tue, 9 Jun 2026 13:49:08 +0300 Subject: [PATCH 1/4] Delete external --- external/dash-notice | 1 - sql.txt | 8 -------- 2 files changed, 9 deletions(-) delete mode 160000 external/dash-notice delete mode 100644 sql.txt 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/sql.txt b/sql.txt deleted file mode 100644 index 683c9b7..0000000 --- a/sql.txt +++ /dev/null @@ -1,8 +0,0 @@ -CREATE TABLE IF NOT EXISTS `wp_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=utf8 AUTO_INCREMENT=1; From fb1a2b3b537bfbf4a48eba05cdd3a0bf512c0eea Mon Sep 17 00:00:00 2001 From: Lena Stergatou Date: Tue, 9 Jun 2026 14:04:12 +0300 Subject: [PATCH 2/4] version 2.0 * WordPress 7.0 compatibility * Delete external folder --- changelog.txt | 6 + tips.php | 545 ++++++++++++++++++++++++++++---------------------- 2 files changed, 310 insertions(+), 241 deletions(-) diff --git a/changelog.txt b/changelog.txt index ea28df2..115b046 100644 --- a/changelog.txt +++ b/changelog.txt @@ -2,6 +2,12 @@ == Changelog == += 2.0.0 = +* Tested for WordPress 7.0 and PHP 8.1+ +* Fixed some bugs +* Removed external folder +* Removed sql.txt file + = 1.0.7.7 = * Fix: PHP error : Trying to get property of non-object diff --git a/tips.php b/tips.php index e86d2cd..b506560 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_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; + if ( get_site_option( 'tips_version' ) !== $tips_current_version ) { + tips_global_install(); + } } -function tips_blog_install() { - global $wpdb, $tips_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' ); } } +/** + * Installs or updates the global database table for the tips plugin. + * + * This function handles the creation of the custom 'tips' table upon initial + * installation, configures character collation, and manages database schema updates + * (such as adding the 'tip_status' column) for older versions. + * + * @since 1.0.0 + * @version 1.1 + * + * @global wpdb $wpdb WordPress database abstraction object. + * @global string $tips_current_version The current version of the tips plugin. + * + * @return void + */ 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 ) { + + $table_name = $wpdb->base_prefix . 'tips'; + + // Check if column 'tip_status' already exists + $column_exists = $wpdb->get_results( $wpdb->prepare( + "SHOW COLUMNS FROM `$table_name` LIKE %s", + 'tip_status' + ) ); + + // If tip_status doesn't exist ALTER + if ( empty( $column_exists ) ) { + $tips_table1 = 'ALTER TABLE `' . $table_name . "` 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` ( - `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};"; - + $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`) + ) {$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, esc_html__( 'Tips', 'tips' ), esc_html__( '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 +193,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; ?> -

[ ]

[ ]

+

[ ]

[ ]