Skip to content

Commit

Permalink
Merge branch 'release/2.1' into feature/gutenberg-donation-form-block
Browse files Browse the repository at this point in the history
* release/2.1: (39 commits)
  fix(dashboard-widget): incorrect stat for this year #2847
  fix(cache): typo in text domain
  fix(cache): typo in function name
  feat(admin-plugin): Add Give menu in plugin menu section #2278
  fix(compat): resolve caching conflict with W3TC
  fix(form): #2838
  fix(compat): Change hook that load give text domain #2784
  style(code): improve formatting
  fix(form): sanitize default minimum amount
  fix(donation): Change Minimum Amount to 1.0 if empty  #2819
  fix(phpcs): Fix phpcs error #2819
  refactor(donation): Remove unwanted condition check #2819
  fix(donation): Fix amount format #2819
  fix(donation): Fix minimum donation amount check #2819
  refactor(import-settings): use core functions and sanitize $_POST
  feat(export): Make checkbox fields for export checked by default
  feat(export): Add feature to selectively export fields
  fix(media-uploads): upload file to correct folder
  fix(cache): prevent possible cache  conflict on multisite
  fix(db): use get_offset fn instead of repeatable logic
  ...
  • Loading branch information
DevinWalker committed Feb 28, 2018
2 parents ebff4dc + 0ddb6cf commit 0dccd5d
Show file tree
Hide file tree
Showing 19 changed files with 387 additions and 568 deletions.
484 changes: 0 additions & 484 deletions assets/css/chosen.css

This file was deleted.

1 change: 1 addition & 0 deletions assets/src/css/admin/give-admin.scss
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
@import '../frontend/variables';
@import '../plugins/jquery-ui-fresh';
@import '../plugins/hint.min';
@import '../plugins/chosen.min';
@import '../frontend/fonts';

@import 'fonts';
Expand Down
10 changes: 10 additions & 0 deletions assets/src/css/admin/reports.scss
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,16 @@ body.give_forms_page_give-reports table.export-options-table {

}

.settings-excludes-list {
max-height: 120px;
overflow: auto;
padding: 0.5rem;
border: 1px solid #ddd;
}

.settings-excludes-list li {
margin: 3px 0;
}
//---------------------------------------------------------
//Recount Stats Form
//---------------------------------------------------------
Expand Down
3 changes: 3 additions & 0 deletions give.php
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,9 @@ public function __construct() {
private function init_hooks() {
register_activation_hook( GIVE_PLUGIN_FILE, 'give_install' );
add_action( 'plugins_loaded', array( $this, 'init' ), 0 );

// Set up localization on init Hook.
add_action( 'init', array( $this, 'load_textdomain' ), 0 );
}

/**
Expand Down
2 changes: 1 addition & 1 deletion includes/admin/dashboard-widgets.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ function give_dashboard_sales_widget() {
<p class="give-dashboard-stat-total-label"><?php _e( 'Last Month', 'give' ); ?></p>
</td>
<td>
<p class="give-dashboard-stat-total"><?php echo give_currency_filter( give_format_amount( give_get_total_earnings(), array( 'sanitize' => false ) ) ) ?></p>
<p class="give-dashboard-stat-total"><?php echo give_currency_filter( give_format_amount( $stats->get_earnings( 0, 'this_year' ), array( 'sanitize' => false ) ) ) ?></p>

<p class="give-dashboard-stat-total-label"><?php _e( 'This Year', 'give' ); ?></p>
</td>
Expand Down
88 changes: 88 additions & 0 deletions includes/admin/plugins.php
Original file line number Diff line number Diff line change
Expand Up @@ -115,3 +115,91 @@ function give_get_admin_page_menu_title() {

return $title;
}

/**
* Create new menu in plugin section that include all the add-on
*
* @since 2.1.0
*
* @param $plugin_menu
*
* @return mixed
*/
function give_filter_addons_do_filter_addons( $plugin_menu ) {
global $plugins;

foreach ( $plugins['all'] as $plugin_slug => $plugin_data ) {

if ( false !== strpos( $plugin_data['Name'], 'Give' ) && false !== strpos( strtolower( $plugin_data['AuthorName'] ), 'wordimpress' ) ) {
$plugins['give'][ $plugin_slug ] = $plugins['all'][ $plugin_slug ];
$plugins['give'][ $plugin_slug ]['plugin'] = $plugin_slug;
// replicate the next step
if ( current_user_can( 'update_plugins' ) ) {
$current = get_site_transient( 'update_plugins' );
if ( isset( $current->response[ $plugin_slug ] ) ) {
$plugins['give'][ $plugin_slug ]['update'] = true;
}
}

}
}

return $plugin_menu;

}

add_filter( 'show_advanced_plugins', 'give_filter_addons_do_filter_addons' );

/**
* Make the Give Menu as an default menu and update the Menu Name
*
* @since 2.1.0
*
* @param $views
*
* @return mixed
*/
function give_filter_addons_filter_addons( $views ) {

global $status, $plugins;

if ( ! empty( $plugins['give'] ) ) {
$class = "";

if ( $status == 'give' ) {
$class = 'current';
}

$views['give'] = sprintf(
'<a class="%s" href="plugins.php?plugin_status=give"> %s <span class="count">(%s) </span></a>',
$class,
__( 'Give', 'give' ),
count( $plugins['give'] )
);
}

return $views;
}

add_filter( 'views_plugins', 'give_filter_addons_filter_addons' );

/**
* Set the Give as the Main menu when admin click on the Give Menu in Plugin section.
*
* @since 2.1.0
*
* @param $plugins
*
* @return mixed
*/
function give_prepare_filter_addons( $plugins ) {
global $status;

if ( isset( $_REQUEST['plugin_status'] ) && $_REQUEST['plugin_status'] === 'give' ) {
$status = 'give';
}

return $plugins;
}

add_filter( 'all_plugins', 'give_prepare_filter_addons' );
14 changes: 7 additions & 7 deletions includes/admin/shortcodes/abstract-shortcode-generator.php
Original file line number Diff line number Diff line change
Expand Up @@ -290,15 +290,15 @@ protected function generate_post( $field ) {
);

$args = wp_parse_args( (array) $field['query_args'], $args );
$posts = new WP_Query( $args );
$posts = get_posts( $args );
$options = array();

if ( $posts->have_posts() ) {
while ( $posts->have_posts() ) {
$posts->the_post();
$post_title = get_the_title();
$post_id = get_the_ID();
$options[ absint( $post_id ) ] = ( empty( $post_title ) ? sprintf( __( 'Untitled (#%s)', 'give' ), $post_id ) : $post_title );
if ( ! empty( $posts ) ) {
/* @var WP_Post $post */
foreach ( $posts as $post ) {
$options[ absint( $post->ID ) ] = empty( $post->post_title ) ?
sprintf( __( 'Untitled (#%s)', 'give' ), $post->ID ) :
apply_filters( 'the_title', $post->post_title );
}

$field['type'] = 'listbox';
Expand Down
13 changes: 12 additions & 1 deletion includes/admin/tools/export/class-core-settings-export.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,18 @@ public function headers() {
* @since 1.8.17
*/
public function json_core_settings_export() {
echo wp_json_encode( get_option( 'give_settings' ) );
$settings_excludes = give_clean( $_POST['settings_export_excludes'] );
$give_settings = get_option( 'give_settings' );

if ( is_array( $settings_excludes ) && ! empty( $settings_excludes ) ) {
foreach ( $settings_excludes as $key => $value ) {
if ( give_is_setting_enabled( $value ) ) {
unset( $give_settings[ $key ] );
}
}
}

echo wp_json_encode( $give_settings );
}

/**
Expand Down
21 changes: 21 additions & 0 deletions includes/admin/tools/views/html-admin-page-exports.php
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,27 @@ class="give-clearfix">
</td>
<td>
<form method="post">
<p class="settings-excludes-title"><?php echo __( 'Checked options from the list will not be exported', 'give' ); ?></p>
<ul class="settings-excludes-list">
<?php
$export_excludes = apply_filters( 'settings_export_excludes', array() );

if ( ! empty( $export_excludes ) ) {
foreach ( $export_excludes as $option_key => $option_label ) {
?>
<li>
<label for="settings_export_excludes[<?php echo $option_key?>]">
<input
type="checkbox" checked
name="settings_export_excludes[<?php echo $option_key?>]"
id="settings_export_excludes[<?php echo $option_key?>]"><?php echo esc_html( $option_label ); ?>
</label>
</li>
<?php
}
}
?>
</ul>
<input type="hidden" name="give-action" value="core_settings_export"/>
<input type="submit" value="<?php esc_attr_e( 'Export JSON', 'give' ); ?>" class="button-secondary"/>
</form>
Expand Down
57 changes: 31 additions & 26 deletions includes/admin/upgrades/class-give-updates.php
Original file line number Diff line number Diff line change
Expand Up @@ -510,6 +510,9 @@ public function __health_background_update( $give_updates ) {
if ( self::$background_updater->has_queue() ) {
$this->__health_background_update( $this );
} else {
delete_site_transient( self::$background_updater->get_identifier() . '_process_lock' );
wp_clear_scheduled_hook( self::$background_updater->get_cron_identifier() );

self::$background_updater->complete();
}

Expand All @@ -518,22 +521,11 @@ public function __health_background_update( $give_updates ) {
$log_data .= 'Updating batch' . "\n";
$log_data .= print_r( $batch, true );

$doing_upgrade_args['heading'] = sprintf( 'Update %s of %s', $doing_upgrade_args['update'], get_option( 'give_db_update_count' ) );
$doing_upgrade_args['total_percentage'] = $this->get_db_update_processing_percentage();
update_option( 'give_doing_upgrade', $doing_upgrade_args );

if ( ! empty( $batch->key ) ) {
wp_cache_delete( $batch->key, 'options' );
update_option( $batch->key, $batch->data );
} else {

update_option( 'give_db_update_count', count( $batch->data ) );

$doing_upgrade_args['update'] = $give_updates->update;
$doing_upgrade_args['heading'] = sprintf( 'Update %s of %s', 1, count( $batch->data ) );

update_option( 'give_doing_upgrade', $doing_upgrade_args );

foreach ( $batch->data as $data ) {
Give_Updates::$background_updater->push_to_queue( $data );
}
Expand All @@ -546,27 +538,24 @@ public function __health_background_update( $give_updates ) {
/**
* Fix give_doing_upgrade option
*/
$update_option = false;
$fresh_new_db_count = $this->get_total_new_db_update_count( true );
if ( $fresh_new_db_count < $doing_upgrade_args['update'] ) {
update_option( 'give_db_update_count', $fresh_new_db_count );
$doing_upgrade_args['update'] = 1;
$doing_upgrade_args['heading'] = sprintf( 'Update %s of %s', 1, $fresh_new_db_count );
$update_option = true;
}

if ( 101 < $doing_upgrade_args['total_percentage'] ) {
$doing_upgrade_args['total_percentage'] = $this->get_db_update_processing_percentage( true );
$update_option = true;
}
update_option( 'give_db_update_count', $fresh_new_db_count );

if ( $update_option ) {
update_option( 'give_doing_upgrade', $doing_upgrade_args );
$doing_upgrade_args['update'] = 1;
$doing_upgrade_args['heading'] = sprintf( 'Update %s of %s', 1, $fresh_new_db_count );
$doing_upgrade_args['total_percentage'] = $this->get_db_update_processing_percentage( true );

$log_data .= 'Updated doing update:' . "\n";
$log_data .= print_r( $doing_upgrade_args, true ) . "\n";
// Remove already completed update from info.
if ( give_has_upgrade_completed( $doing_upgrade_args['update_info']['id'] ) ) {
$doing_upgrade_args['update_info'] = current( array_values( $batch->data ) );
$doing_upgrade_args['step'] = 1;
}

update_option( 'give_doing_upgrade', $doing_upgrade_args );

$log_data .= 'Updated doing update:' . "\n";
$log_data .= print_r( $doing_upgrade_args, true ) . "\n";
Give()->logs->add( 'Update Health Check', $log_data, 0, 'update' );
}

Expand Down Expand Up @@ -1138,6 +1127,22 @@ public function get_update_ids() {

return $all_update_ids;
}

/**
* Get offset count
*
* @since 2.0.5
* @access public
*
* @param int $process_item_count
*
* @return float|int
*/
public function get_offset( $process_item_count ) {
return ( 1 === $this->step ) ?
0 :
( $this->step - 1 ) * $process_item_count;
}
}

Give_Updates::get_instance()->setup();

0 comments on commit 0dccd5d

Please sign in to comment.