Skip to content

Commit

Permalink
PROJ-1885 Expand auto-recurring to membership autorenewal.
Browse files Browse the repository at this point in the history
  • Loading branch information
agileware-fj authored and agileware-dev committed Aug 9, 2021
1 parent 5e424fb commit 704b30a
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 8 deletions.
9 changes: 6 additions & 3 deletions admin/partials/civicrm-ux-admin-display.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,15 @@ function civicrm_ux_settings_page() {
<tr vlign="top">
<td colspan="2"><label><input type="checkbox" name="civicrm_contribution_ux[is_recur_default]"<?php if ($opt_c['is_recur_default']) echo ' checked="checked"'; ?>>Set contributions as recurring by default</label></td>
</tr>
<tr vlign="top">
<td colspan="2"><label><input type="checkbox" name="civicrm_contribution_ux[is_autorenew_default]"<?php if ($opt_c['is_autorenew_default']) echo ' checked="checked"'; ?>>Set memberships as autorenewal by default</label></td>
</tr>
</table>
</div>
<?php submit_button(); ?>
<div>
<a href="/wp-content/plugins/civicrm-ux/admin/partials/civicrm-ux-guide.html" target="_blank">CiviCRM UX guide</a>
</div>
<?php /** The documentation in this file is outdated <div>
<a href="<?php echo plugin_dir_url(__FILE__) . 'civicrm-ux-guide.html'; ?>" target="_blank">CiviCRM UX guide</a>
</div> /**/ ?>
</form>
</div>
<?php }
4 changes: 2 additions & 2 deletions civicrm-ux.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* Plugin Name: WP CiviCRM UX
* Plugin URI: https://github.com/agileware/wp-civicrm-ux
* Description: A better user experience for integrating WordPress and CiviCRM
* Version: 1.7.1
* Version: 1.8.0
* Author: Agileware
* Author URI: https://agileware.com.au/
* License: GPL-2.0+
Expand All @@ -24,7 +24,7 @@
* Start at version 1.0.0 and use SemVer - https://semver.org
* Rename this for your plugin and update it as you release new versions.
*/
define( 'CIVICRM_UXVERSION', '1.7.1' );
define( 'CIVICRM_UXVERSION', '1.8.0' );

// If this file is called directly, abort.
if ( ! defined( 'WPINC' ) ) {
Expand Down
7 changes: 4 additions & 3 deletions public/class-civicrm-ux-public.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,11 +99,12 @@ public function enqueue_scripts() {

wp_enqueue_script( $this->civicrm_ux, plugin_dir_url( __FILE__ ) . 'js/civicrm-ux-public.js', [ 'jquery' ], $this->version, false );

$options_map = [];

$opt = Civicrm_Ux::getInstance()->get_store()->get_option( 'civicrm_contribution_ux' );

$options_map['is_recur_default'] = !! $opt['is_recur_default'];
$options_map = [
'is_recur_default' => !! $opt['is_recur_default'],
'is_autorenew_default' => !! $opt['is_autorenew_default'],
];

wp_add_inline_script($this->civicrm_ux, 'window.wp = window.wp || ({}); window.wp.CiviCRM_UX = (' . json_encode($options_map) . ')', 'before');

Expand Down
4 changes: 4 additions & 0 deletions public/js/civicrm-ux-public.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@
jQuery('.is_recur-section :input').prop('disabled', false);
jQuery(':input[name=is_recur]').prop('checked', 'checked');
}
if(wp.CiviCRM_UX.is_autorenew_default && !jQuery(':input[name=auto_renew]').prop('disabled')) {
jQuery('.auto_renew_section :input').prop('disabled', false);
jQuery(':input[name=auto_renew]').prop('checked', 'checked');
}
});

})(jQuery);

0 comments on commit 704b30a

Please sign in to comment.