Plugin Directory

Changeset 2370598


Ignore:
Timestamp:
08/27/2020 08:21:12 PM (5 years ago)
Author:
concertedaction
Message:

upgrade to version 1.2

Location:
wp-action-network/trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • wp-action-network/trunk/actionnetwork.php

    r2100004 r2370598  
    22/*
    33 * @package ActionNetwork
    4  * @version 1.1.3
     4 * @version 1.2
    55 *
    66 * Plugin Name: Action Network
     
    99 * Text Domain: actionnetwork
    1010 * Domain Path: /languages
    11  * Version: 1.1.3
     11 * Version: 1.2
    1212 * License: GPLv3
    1313 * Author URI: http://concertedaction.consulting
     
    3434 */
    3535global $actionnetwork_version;
    36 $actionnetwork_version = '1.1.3';
     36$actionnetwork_version = '1.2';
    3737global $actionnetwork_db_version;
    3838$actionnetwork_db_version = '1.0.7';
     
    5050
    5151    if ($installed_version != $actionnetwork_version) {
     52
     53                // test for particular updates here
     54        if ($actionnetwork_version == '1.2') {
     55            $notices[] = sprintf(
     56                /* translators: %s is a link to https://wordpress.org/plugins/wp-action-network/ */
     57                __('The %s has been updated to version 1.2. This major update includes the following updates: - hCaptcha ability added for API based forms. - Bug fixes related too multiple embeds on a single page, and the API sync. - shortcode button for tinymce WYSIWYG. - additional documentation on setting page. Backing up site before upgrading is recommended.', 'actionnetwork'),
     58                '<a href="https://wordpress.org/plugins/wp-action-network/">Action Network plugin</a>'
     59                );
     60        }
     61
    5262
    5363                // test for particular updates here
     
    716726   
    717727    switch ($_REQUEST['actionnetwork_admin_action']) {
     728
     729        case 'update_spam_keys':
     730            update_option('actionnetwork_hcaptcha_site_key', $_REQUEST['actionnetwork_hcaptcha_site_key']);
     731            update_option('actionnetwork_hcaptcha_secret_key', $_REQUEST['actionnetwork_hcaptcha_secret_key']);
     732        break;
    718733   
    719734        case 'update_api_key':
     
    731746            $debug .= "get_option did not match actionnetwork_api_key\n";
    732747           
     748            echo "---\n";
    733749            // don't allow API Key to be changed if a sync queue is processing
    734750            if ($queue_status != 'empty') {
     
    764780               
    765781                $debug .= $actionnetwork_api_key_is_valid ? "actionnetwork_api_key is valid\n" : "actionnetwork_api_key is not valid\n";
    766                
     782                //echo "---\n";
     783               
    767784                if ($actionnetwork_api_key_is_valid) {
    768785           
     
    775792                        // initiate a background process by making a call to the "ajax" URL
    776793                        $ajax_url = admin_url( 'admin-ajax.php' );
    777 
     794                        //$ajax_url = get_site_url(). '/wp-admin/admin-ajax.php';
     795                       
    778796                        // since we're making this call from the server, we can't use a nonce
    779797                        // because the user id would be different. so create a token
     
    783801                        update_option( 'actionnetwork_ajax_token', $token );
    784802
    785                         $body = array(
     803                        /*$body = array(
    786804                            'action' => 'actionnetwork_process_queue',
    787805                            'queue_action' => 'init',
    788806                            'token' => $token,
    789807                        );
    790                         $args = array( 'body' => $body, 'timeout' => 1 );
    791                         wp_remote_post( $ajax_url, $args );
    792 
     808                        $args = array( 'body' => $body, 'timeout' => 30 );
     809                        //echo "POST RESPONSE:\n";
     810                        $response = wp_remote_post( $ajax_url, $args );
     811                        //print_r($response);*/
     812                       
     813                        $_REQUEST['action'] = 'actionnetwork_process_queue';
     814                        $_REQUEST['queue_action'] = 'init';
     815                        $_REQUEST['token'] = $token;
     816                        actionnetwork_process_queue();
     817                       
    793818                        $queue_status = 'processing';
    794819                        $return['queue_status'] = $queue_status;
     
    806831            }
    807832        }
     833        //echo $debug. "\n";
     834       
    808835        break;
    809836
     
    12501277    // get API Key
    12511278    $actionnetwork_api_key = get_option('actionnetwork_api_key');
     1279
     1280    // get hCaptcha keys
     1281    $hcaptcha_site_key = get_option('actionnetwork_hcaptcha_site_key');
     1282    $hcaptcha_secret_key = get_option('actionnetwork_hcaptcha_secret_key');
    12521283   
    12531284    // get queue status - allow action_returns to override the option because
     
    13191350                <a href="#actionnetwork-settings" class="nav-tab<?php echo ($tab == 'settings') ? ' nav-tab-active' : ''; ?>">
    13201351                    <?php _e('Settings', 'actionnetwork'); ?>
     1352                </a>
     1353
     1354                <a href="#actionnetwork-about" class="nav-tab<?php echo ($tab == 'about') ? ' nav-tab-active' : ''; ?>">
     1355                    <?php _e('About', 'actionnetwork'); ?>
    13211356                </a>
    13221357            </h2>
     
    14471482                    <p class="submit"><input type="submit" id="actionnetwork-options-form-submit" class="button-primary" value="<?php _e('Save Settings', 'actionnetwork'); ?>" /></p>
    14481483                </form>
     1484                <h2><?php _e('Plugin Captcha Settings', 'actionnetwork'); ?></h2>
     1485                <p>In order to be able to activate anti-spam challenges you have to fill up the forms bellow. In order to get the keys all you have to do is create
     1486                an account on <a href="https://hcaptcha.com" target="_blank">hcaptcha.com</a>.</p>
     1487                <form method="post" action="">
     1488                    <?php
     1489                        wp_nonce_field( 'actionnetwork_update_spam_keys', 'actionnetwork_nonce_field' );
     1490                    ?>
     1491                    <input type="hidden" name="actionnetwork_admin_action" value="update_spam_keys" />
     1492                    <input type="hidden" name="actionnetwork_tab" value="settings" />
     1493
     1494                    <table class="form-table"><tbody>
     1495                        <tr valign="top">
     1496                            <th scope="row"><label for="actionnetwork_hcaptcha_site_key"><?php _e('hCaptcha Site Key', 'actionnetwork'); ?></label></th>
     1497                            <td>
     1498                                <input id="actionnetwork_hcaptcha_site_key" style="min-width: 400px" name="actionnetwork_hcaptcha_site_key" type="text" value="<?php esc_attr_e($hcaptcha_site_key); ?>" />
     1499                            </td>
     1500                        </tr>
     1501                        <tr valign="top">
     1502                            <th scope="row"><label for="actionnetwork_hcaptcha_secret_key"><?php _e('hCaptcha Secret Key', 'actionnetwork'); ?></label></th>
     1503                            <td>
     1504                                <input id="actionnetwork_hcaptcha_secret_key" style="min-width: 400px" name="actionnetwork_hcaptcha_secret_key" type="text" value="<?php esc_attr_e($hcaptcha_secret_key); ?>" />
     1505                            </td>
     1506                        </tr>
     1507                    </tbody></table>
     1508                    <p class="submit"><input type="submit" id="actionnetwork-options-form-submit" class="button-primary" value="<?php _e('Save Settings', 'actionnetwork'); ?>" /></p>
     1509                </form>
    14491510            </div>
    1450        
     1511
     1512            <?php /* options about */ ?>
     1513            <div class="actionnetwork-admin-tab<?php echo ($tab == 'about') ? ' actionnetwork-admin-tab-active' : ''; ?>" id="actionnetwork-about">
     1514                <h2><?php _e('About the Plugin', 'actionnetwork'); ?></h2>
     1515                                <style type="text/css">
     1516                    #can-form-area-wordpress-plugin-users-list h2 {text-align: center; border-bottom: none !important;}
     1517                    #can-form-area-wordpress-plugin-users-list h4, #can-form-area-wordpress-plugin-users-list #action_info, #can-form-area-wordpress-plugin-users-list #d_sharing {display: none !important;}
     1518                </style>
     1519                <div style="width: 64%; float: left;"><p>This plugin is maintained by <a href="https://concertedaction.consulting/" target="_blank">Concerted Action</a> a one-stop consulting firm specializing in advocacy, organizing and the digital tools that power grassroots movements.</p>
     1520
     1521                <p>Learn more about us on our <a href="https://concertedaction.consulting/" target="_blank">website</a>, <a href="https://www.facebook.com/concertedaction" target="_blank">Facebook</a>, <a href="https://twitter.com/ConcertedAct" target="_blank">Twitter</a> or <a href="https://www.linkedin.com/company/concertedaction" target="_blank">LinkedIn</a>.</p>
     1522                <p>Sign up using the form to stay informed about future updates to the Action Network WordPress plugin, and have opportunities to provide feedback and make suggestions about the plugin's development roadmap.</p>
     1523
     1524            </div>
     1525
     1526                <div style="width: 35%; float: right;">
     1527                   
     1528                <link href='https://actionnetwork.org/css/style-embed-whitelabel-v3.css' rel='stylesheet' type='text/css' /><script src='https://actionnetwork.org/widgets/v3/form/wordpress-plugin-users-list?format=js&source=widget'></script><div id='can-form-area-wordpress-plugin-users-list' style='width: 100%'><!-- this div is the target for our HTML insertion --></div>
     1529            </div>
     1530            </div>
    14511531        </div> <!-- /.wrap-inner -->
    14521532
     
    15921672}
    15931673
     1674// hooks your functions into the correct filters
     1675function wdm_add_mce_button() {
     1676
     1677    global $wpdb;
     1678
     1679    // check user permissions
     1680    if ( !current_user_can( 'edit_posts' ) &&  !current_user_can( 'edit_pages' ) ) {
     1681        return;
     1682    }
     1683
     1684    global $wpdb;
     1685
     1686    $results        = $wpdb->get_results ( "SELECT * FROM {$wpdb->prefix}actionnetwork WHERE enabled = '1'" );
     1687    $results_array  = array();
     1688    $results_count  = count( $results );
     1689    $result_itr     = 0;
     1690
     1691    if( $results ){
     1692        foreach( $results as $result ){
     1693            $result_itr++;
     1694            $results_array[$result_itr] = array( $result->wp_id, $result->title ) ;
     1695        }
     1696
     1697    }
     1698
     1699    $script_decode = json_encode( $results_array );
     1700
     1701    $script = <<<EOF
     1702   <script type = 'text/javascript'>
     1703        var actionnetwork_shortcode = $script_decode;
     1704   </script>
     1705EOF;
     1706    echo $script;
     1707
     1708    // check if WYSIWYG is enabled
     1709    if ( 'true' == get_user_option( 'rich_editing' ) ) {
     1710        add_filter( 'mce_external_plugins', 'wdm_add_tinymce_plugin', 22, 1 );
     1711        add_filter( 'mce_buttons', 'wdm_register_mce_button' );
     1712    }
     1713}
     1714add_action('admin_head', 'wdm_add_mce_button');
     1715
     1716// register new button in the editor
     1717function wdm_register_mce_button( $buttons ) {
     1718    array_push( $buttons, 'wdm_mce_button' );
     1719    return $buttons;
     1720}
     1721
     1722
     1723// declare a script for the new button
     1724// the script will insert the shortcode on the click event
     1725function wdm_add_tinymce_plugin( $plugin_array ) {
     1726
     1727    $plugin_array['wdm_mce_button'] =  plugin_dir_url( __FILE__ ). 'admin-wsywyg.js';
     1728    return $plugin_array;
     1729
     1730}
  • wp-action-network/trunk/includes/actionnetwork-sync.class.php

    r2032205 r2370598  
    9595       
    9696        // check process time
    97         $time_elapsed = time() - $this->processStartTime;
     97        /*$time_elapsed = time() - $this->processStartTime;
    9898        if ( $time_elapsed > 20 ) { $start_new_process = true; }
    9999       
     
    124124            wp_die();
    125125            return;
    126         }
     126        }*/
    127127       
    128128        // process the next resource
  • wp-action-network/trunk/includes/actionnetwork-widgets.class.php

    r1793252 r2370598  
    616616       
    617617        wp_enqueue_style( 'actionnetwork-signup-css', plugins_url('../signup.css', __FILE__) );
     618
    618619        echo $args['before_widget'];
    619620        if (!empty( $instance['title'])) {
     
    635636            'item_element' => 'li',
    636637            'item_class' => 'actionnetwork-signup-item',
     638            'spam_protect' => 0,
    637639        );
    638640        foreach ($defaults as $key => $value) {
     
    640642        }
    641643        extract($instance);
     644
     645        if($spam_protect){
     646            wp_enqueue_script( 'actionnetwork-hcaptcha', 'https://www.hCaptcha.com/1/api.js' );
     647            $hcaptcha_site_key = get_option('actionnetwork_hcaptcha_site_key');
     648            $hcaptcha_secret_key = get_option('actionnetwork_hcaptcha_secret_key');
     649        }
    642650       
    643651        if (isset($submission['message']) && $submission['message']) {
     
    694702        $form .= isset($errors['zip_code']) ? "<label class=\"error\" for=\"{$args['widget_id']}-zip-code\">".$errors['zip_code']."</label>" : '';
    695703        $form .= "</$item_element>";
     704
     705        // hCaptcha
     706        if($spam_protect){
     707            $form .= "<$item_element class=\"h-captcha\" data-sitekey=\"$hcaptcha_site_key\"></$item_element>";
     708        }
    696709       
    697710        // submit button
     
    725738        // verify
    726739        $submission['errors'] = array();
    727        
     740
     741        // Check for captcha result
     742        if($spam_protect){
     743            if(isset($data['g-recaptcha-response']) && !empty($data['g-recaptcha-response'])) {
     744                $data = array('secret' => $hcaptcha_secret_key,'response' => $data['g-recaptcha-response']);
     745
     746                $verify = curl_init();
     747                curl_setopt($verify, CURLOPT_URL, "https://hcaptcha.com/siteverify");
     748                curl_setopt($verify, CURLOPT_POST, true);
     749                curl_setopt($verify, CURLOPT_POSTFIELDS, http_build_query($data));
     750                curl_setopt($verify, CURLOPT_RETURNTRANSFER, true);
     751       
     752                $response = curl_exec($verify);
     753                $responseData = json_decode($response);
     754       
     755                if(!$responseData->success) {
     756                    $submission['errors']['captcha'] = __('We could not confirm the captcha. Please try again.','actionnetwork');
     757                }
     758            }else{
     759                $submission['message'] = wpautop( __('Please complete the captcha challenge.', 'actionnetwork') );
     760                return $submission;
     761            }
     762        }
     763       
     764        // Check for required fields
    728765        if (isset($instance['first_name_require']) && $instance['first_name_require'] && !$submission['first_name']) {
    729766            $submission['errors']['first_name'] = __('This field is required','actionnetwork');
     
    883920                'description' => __( 'If checked, form will be submitted without loading a new page', 'actionnetwork' ),
    884921            ),
     922            'spam_protect' => array(
     923                'label' => __('Spam protection', 'actionnetwork'),
     924                'type' => 'checkbox',
     925                'default' => 0,
     926                'advanced' => false,
     927                'description' => __( 'If checked, a hCaptcha challenge will be added to the form', 'actionnetwork' ),
     928            ),
    885929            'thank_you_message' => array(
    886930                'label' => __('Thank you message', 'actionnetwork'),
    887931                'type' => 'textarea',
     932                'default' => 'Thank you for signing up!',
    888933                'advanced' => false,
    889934                'description' => __( 'Text to display after successful signup. If left blank, will default to "Thank you for signing up!" <code>wpautop</code> will be applied (adding line breaks). Accepts HTML.', 'actionnetwork' ),
     
    954999            'item_element',
    9551000            'item_class',
     1001            'spam_protect',
    9561002        );
    9571003        foreach ($sanitize_args as $arg) {
  • wp-action-network/trunk/readme.txt

    r2100487 r2370598  
    11=== Action Network ===
    2 Contributors: concertedaction, jonathankissam
     2Contributors: concertedaction
    33Tags: signup, events, action network, online organizing
    44Requires at least: 4.6
    5 Tested up to: 5.2.1
    6 Stable tag: 1.1.3
     5Tested up to: 5.5
     6Stable tag: 1.2
    77License: GPLv3 or later
    88License URI: https://www.gnu.org/licenses/gpl.html
     
    1212== Description ==
    1313
    14 A free Wordpress plugin for the [Action Network](https://actionnetwork.org) online organizing tools maintained by [Concerted Action](http://concertedaction.consulting/) originally developed by [Jonathan Kissam](http://jonathankissam.com/).
     14A free Wordpress plugin for the [Action Network](https://actionnetwork.org) online organizing tools maintained by [Concerted Action](http://concertedaction.consulting/).
    1515
    1616Features:
     
    2424* Create signup widgets which allow visitors to your site to sign up for your email list _without_ using Action Network javascript embeds. This allows you to place a signup form on every page (for example in the sidebar), and still load Action Network embed codes for actions on particular pages (since Action Network's scripts will only load one embed code per page).  This feature does require the API key, so you have to be an [Action Network Partner](https://actionnetwork.org/partnerships) to use it.
    2525
    26 Detailed specs for shortcode attributes, widget options, etc. are available on the Help menu for the Action Network page on the backend, or in [this blog post](https://jonathankissam.wordpress.com/2017/12/27/new-version-of-my-action-network-plugin/)
     26Detailed specs for shortcode attributes, widget options, etc. are available on the Help menu for the Action Network page on the backend.
    2727
    2828== Installation ==
     
    4444== Changelog ==
    4545
     46= 1.2 =
     47
     48* This major update includes the following updates:
     49* hCaptcha ability added for API based forms.
     50* Bug fixes related too multiple embeds on a single page, and the API sync.
     51* shortcode button for tinymce WYSIWYG.
     52* additional documentation on setting page.
     53
    4654= 1.1.3 =
    4755
    48 Updating developer information.
     56* Updating developer information.
    4957
    5058= 1.1.2 =
     
    7179
    7280= 1.1.0 =
    73 New features, including new widgets, shortcodes, and shortcode options, as well as ajax submission of the signup form. [Read more](https://jonathankissam.wordpress.com)
     81New features, including new widgets, shortcodes, and shortcode options, as well as ajax submission of the signup form.
    7482
    7583= 1.0.1 =
Note: See TracChangeset for help on using the changeset viewer.