Skip to content

Commit

Permalink
Merge pull request #30 from agileware/WPCIVIUX-126
Browse files Browse the repository at this point in the history
Refactor the Settings page, remove invalid HTML, fix spelling and use CSS for row alignment, fix implied variable names.
  • Loading branch information
agileware-justin authored Feb 2, 2023
2 parents bf46004 + d3ef173 commit af0d497
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 58 deletions.
103 changes: 49 additions & 54 deletions admin/partials/civicrm-ux-admin-display.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,106 +13,101 @@
*/

function civicrm_ux_settings_page() {
$url_param = [
'hash' => get_option( Civicrm_Ux_Shortcode_Event_ICal_Feed::HASH_OPTION ),
];
$url = add_query_arg(
$url_param,
get_rest_url( NULL,
'/' . Civicrm_Ux_Shortcode_Event_ICal_Feed::API_NAMESPACE . '/' . Civicrm_Ux_Shortcode_Event_ICal_Feed::INTERNAL_ENDPOINT ) );
$opt = Civicrm_Ux::getInstance()
->get_store()
->get_option( 'civicrm_summary_options' );
$opt_c = Civicrm_Ux::getInstance()
->get_store()
->get_option( 'civicrm_contribution_ux' );
?>
$url_param = [
'hash' => get_option(Civicrm_Ux_Shortcode_Event_ICal_Feed::HASH_OPTION),
];
$url = add_query_arg(
$url_param,
get_rest_url(NULL,
'/' . Civicrm_Ux_Shortcode_Event_ICal_Feed::API_NAMESPACE . '/' . Civicrm_Ux_Shortcode_Event_ICal_Feed::INTERNAL_ENDPOINT));
$opt_summary_options = Civicrm_Ux::getInstance()
->get_store()
->get_option('civicrm_summary_options');
$opt_contribution_ux = Civicrm_Ux::getInstance()
->get_store()
->get_option('civicrm_contribution_ux');
?>
<div class="wrap">
<h1>CiviCRM UX</h1>
<h2>Usage Documentation</h2>
<p>Documentation on the available shortcodes and functionality for this plugin is available on our Github project page, <a href="https://github.com/agileware/wp-civicrm-ux/blob/master/USAGE.md" target="_blank">CiviCRM UX User Guide</a>.</p>
<p>
Documentation on the available shortcodes and functionality for this plugin is available on our Github project page, <a href="https://github.com/agileware/wp-civicrm-ux/blob/master/USAGE.md" target="_blank">CiviCRM UX User Guide</a>.
</p>
<h2>How To Say Thank You!</h2>
<p>If you are using this plugin and find it useful, you can say thank you by <a href="https://www.paypal.me/agileware" target="_blank">buying us a beer or a coffee</a>.</p>
<p>
If you are using this plugin and find it useful, you can say thank you by <a href="https://www.paypal.me/agileware" target="_blank">buying us a beer or a coffee</a>.
</p>
<form method="post" action="options.php">
<?php settings_fields( 'civicrm-ux-settings-group' ); ?>
<?php settings_fields('civicrm-ux-settings-group'); ?>
<div>
<h2>iCal Feed</h2>
<table>
<tr>
<th scope="row"><label
for="ical-hash-field">Hash</label></th>
<td><label for="ical-hash-field">Random Hash</label>
</td>
<td><input id="ical-hash-field" type="text"
name=<?php echo '"' . Civicrm_Ux_Shortcode_Event_ICal_Feed::HASH_OPTION . '"' ?> size="40"
value="<?php echo esc_attr( get_option( Civicrm_Ux_Shortcode_Event_ICal_Feed::HASH_OPTION ) ); ?>"/>
value="<?php echo esc_attr(get_option(Civicrm_Ux_Shortcode_Event_ICal_Feed::HASH_OPTION)); ?>"/>
<!-- TODO fix button -->
<button id="generate-ical-hash" type="button">
GENERATE
Re-generate Hash
</button>
</td>
</tr>
<tr>
<th scope="row"><span>The internal feed url is: </span>
</th>
<td>The internal feed url is:</td>
<td><a id="ical-internal-url"
href="<?php echo $url ?>"><?php echo $url ?></a>
</td>
</tr>
</table>
<h2>Membership Summary</h2>
<table>
<tr valign="top">
<th scope="row"><label
for="civicrm_summary_show_renewal_date">The
number of days to show the
renewal notice and URL</label></th>
<tr style="vertical-align: text-top;">
<td><label for="civicrm_summary_show_renewal_date">The
number of days to show the renewal notice and
URL</label></td>
<td><input type="number" min="0" step="1"
id="civicrm_summary_show_renewal_date"
name="civicrm_summary_options[civicrm_summary_show_renewal_date]"
value="<?php echo $opt['civicrm_summary_show_renewal_date']; ?>"/>
value="<?php echo $opt_summary_options['civicrm_summary_show_renewal_date']; ?>"/>
</td>
</tr>
<tr valign="top">
<th scope="row"><label style="float:left;"
for="civicrm_summary_membership_join_URL">URL
for the
membership join page</label></th>
<tr style="vertical-align: text-top;">
<td><label for="civicrm_summary_membership_join_URL">URL
for the Membership Join page</label></td>
<td><input type="text"
id="civicrm_summary_membership_join_URL"
name="civicrm_summary_options[civicrm_summary_membership_join_URL]"
value="<?php echo $opt['civicrm_summary_membership_join_URL']; ?>"/>
value="<?php echo $opt_summary_options['civicrm_summary_membership_join_URL']; ?>"/>
</td>
</tr>
<tr valign="top">
<th scope="row"><label style="float:left;"
for="civicrm_summary_membership_renew_URL">URL
for
the membership renewal page</label></th>
<tr style="vertical-align: text-top;">
<td><label for="civicrm_summary_membership_renew_URL">URL
for the Membership Renewal page</label></td>
<td><input type="text"
id="civicrm_summary_membership_renew_URL"
name="civicrm_summary_options[civicrm_summary_membership_renew_URL]"
value="<?php echo $opt['civicrm_summary_membership_renew_URL']; ?>"/>
value="<?php echo $opt_summary_options['civicrm_summary_membership_renew_URL']; ?>"/>
</td>
</tr>
</table>
<h2>Contribution Page Tweaks</h2>
<table>
<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 style="vertical-align: text-top;">
<td colspan="2"><input type="checkbox" id="is_recur_default" name="civicrm_contribution_ux[is_recur_default]"
<?php echo isset($opt_contribution_ux['is_recur_default']) ? ' checked="checked">' : '>'; ?>
<label for="is_recur_default">For all Contribution Pages, set the payment to 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 style="vertical-align: text-top;">
<td colspan="2"><input type="checkbox" id="is_autorenew_default" name="civicrm_contribution_ux[is_autorenew_default]"
<?php echo isset($opt_contribution_ux['is_autorenew_default']) ? ' checked="checked">' : '>'; ?>
<label for="is_autorenew_default">For all Membership Contribution Pages, set the membership to auto-renew by default.</label>
</td>
</tr>
</table>
</div>
<?php submit_button(); ?>
<?php submit_button(); ?>
</form>
</div>
<?php }
2 changes: 1 addition & 1 deletion 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.11.3
* Version: 1.11.4
* Requires at least: 5.8
* Requires PHP: 7.4
* Author: Agileware
Expand Down
6 changes: 3 additions & 3 deletions public/class-civicrm-ux-public.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,13 +99,13 @@ public function enqueue_scripts() {

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

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

$options_map = [
'is_recur_default' => ! ! $opt['is_recur_default'],
'is_autorenew_default' => ! ! $opt['is_autorenew_default'],
'is_recur_default' => isset($opt_contribution_ux['is_recur_default']) ? true : false,
'is_autorenew_default' => isset($opt_contribution_ux['is_autorenew_default']) ? true : false,
];

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

0 comments on commit af0d497

Please sign in to comment.