Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge GeoDirectory master #12

Merged
merged 11 commits into from
Nov 22, 2016
45 changes: 44 additions & 1 deletion bp-compliments.php
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,37 @@ function bp_compliments_activate() {
dbDelta( $sql );
update_option( 'bp_compliments_version', BP_COMPLIMENTS_VER );
}

add_option( 'bp_compliments_activation_redirect', 1 );
}

if ( is_admin() ) {
register_activation_hook( __FILE__, 'bp_compliments_activate' );
register_deactivation_hook( __FILE__, 'bp_compliments_deactivate' );
add_filter( 'geodir_plugins_uninstall_settings', 'bp_compliments_uninstall_settings', 10, 1 );
add_action( 'admin_init', 'bp_compliments_activation_redirect' );
}

/**
* Plugin deactivation hook.
*
* @since 1.0.7
*/
function bp_compliments_deactivate() {
// Plugin deactivation stuff.
}

/**
* Redirects user to BuddyPress Compliments settings page after plugin activation.
*
* @since 1.0.7
*/
function bp_compliments_activation_redirect() {
if ( get_option( 'bp_compliments_activation_redirect', false ) ) {
delete_option( 'bp_compliments_activation_redirect' );
wp_redirect( admin_url( 'admin.php?page=bp-compliment-settings' ) );
}
}
register_activation_hook( __FILE__, 'bp_compliments_activate' );

/**
* Custom text domain loader.
Expand Down Expand Up @@ -160,3 +189,17 @@ function bp_compliments_older_version_notice() {

echo '<div class="error"><p>' . $older_version_notice . '</p></div>';
}

/**
* Add the plugin to uninstall settings.
*
* @since 1.0.7
*
* @return array $settings the settings array.
* @return array The modified settings.
*/
function bp_compliments_uninstall_settings($settings) {
$settings[] = plugin_basename(dirname(__FILE__));

return $settings;
}
2 changes: 2 additions & 0 deletions change_log.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
v1.0.7
Send compliment button can be displayed in /members page - ADDED
PHP undefined notices in wordpress admin - FIXED
Option added to remove plugin data on plugin delete - ADDED
Email headers changed from string to array() and MIME-Version removed - CHANGED

v1.0.6
Notification incorrect from email - FIXED
Expand Down
6 changes: 3 additions & 3 deletions includes/bp-compliments-notifications.php
Original file line number Diff line number Diff line change
Expand Up @@ -222,9 +222,9 @@ function bp_compliments_new_compliment_email_notification($args = array()) {
*/
$sitefromEmailName = apply_filters( 'bp_compliments_notification_from_name', $sitefromEmailName );

$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=UTF-8' . "\r\n";
$headers .= 'From: ' . $sitefromEmailName . ' <' . $sitefromEmail . '>' . "\r\n";
$headers = array();
$headers[] = 'Content-type: text/html; charset=UTF-8';
$headers[] = 'From: ' . $sitefromEmailName . ' <' . $sitefromEmail . '>';

// Send the message

Expand Down
70 changes: 70 additions & 0 deletions uninstall.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
<?php
/**
* Uninstall BuddyPress Compliments
*
* Uninstalling BuddyPress Compliments deletes tables and plugin options.
*
* @package BuddyPress_Compliments
* @since 1.0.7
*/

// Exit if accessed directly.
if ( ! defined( 'WP_UNINSTALL_PLUGIN' ) ) {
exit;
}

global $wpdb, $bp;

if ( get_option( 'geodir_un_buddypress-compliments' ) ) {
$wpdb->hide_errors();

if ( !defined( 'BP_COMPLIMENTS_VER' ) ) {
// Load plugin file.
include_once( 'bp-compliments.php' );
}

if ( !( !empty( $bp ) && !empty( $bp->table_prefix ) ) ) {
/** This action is documented in bp-compliments.php */
$table_prefix = apply_filters( 'bp_core_get_table_prefix', $wpdb->base_prefix );
} else {
$table_prefix = $bp->table_prefix;
}

/* Delete all terms & taxonomies. */
$taxonomies = array( 'compliment' );

foreach ( array_unique( array_filter( $taxonomies ) ) as $taxonomy ) {
$terms = $wpdb->get_results( $wpdb->prepare( "SELECT t.*, tt.* FROM $wpdb->terms AS t INNER JOIN $wpdb->term_taxonomy AS tt ON t.term_id = tt.term_id WHERE tt.taxonomy IN ('%s') ORDER BY t.name ASC", $taxonomy ) );

// Delete terms.
if ( $terms ) {
foreach ( $terms as $term ) {
$wpdb->delete( $wpdb->term_taxonomy, array( 'term_taxonomy_id' => $term->term_taxonomy_id ) );
$wpdb->delete( $wpdb->terms, array( 'term_id' => $term->term_id ) );

delete_option( 'taxonomy_' . $term->term_id );
}
}

// Delete taxonomy.
$wpdb->delete( $wpdb->term_taxonomy, array( 'taxonomy' => $taxonomy ), array( '%s' ) );

delete_option( $taxonomy . '_children' );
}

// Delete options
delete_option( 'bp_compliment_singular_name' );
delete_option( 'bp_compliment_plural_name' );
delete_option( 'bp_compliment_slug' );
delete_option( 'bp_compliment_can_see_others_comp' );
delete_option( 'bp_compliment_member_dir_btn' );
delete_option( 'bp_compliment_can_delete' );
delete_option( 'bp_compliment_enable_activity' );
delete_option( 'bp_compliment_enable_notifications' );
delete_option( 'bp_comp_per_page' );
delete_option( 'bp_comp_custom_css' );
delete_option( 'bp_compliments_version' );

// Drop table.
$wpdb->query( "DROP TABLE IF EXISTS " . $table_prefix . "bp_compliments" );
}