Exemplo n.º 1
0
 /**
  * Initialize the plugin by setting localization, filters, and administration functions.
  *
  * @since 1.0.0
  *
  * @access private
  */
 private function __construct()
 {
     global $formworks_tracker;
     //auto load modules
     $dir = FRMWKS_PATH . 'includes/modules';
     if (is_dir($dir)) {
         if ($dh = opendir($dir)) {
             while (($folder = readdir($dh)) !== false) {
                 if ($folder === '..' || $folder === '.') {
                     continue;
                 }
                 if (file_exists($dir . '/' . $folder . '/handler.php')) {
                     include_once $dir . '/' . $folder . '/handler.php';
                 }
             }
             closedir($dh);
         }
     }
     // Load plugin text domain
     add_action('init', array($this, 'load_plugin_textdomain'));
     //initialize visitor tracker
     if (!is_admin()) {
         add_action('wp', array($this, 'register_visitor_session'));
     }
     // Activate plugin when new blog is added
     add_action('wpmu_new_blog', array($this, 'activate_new_site'));
     // Load admin style sheet and JavaScript.
     add_action('admin_enqueue_scripts', array($this, 'enqueue_admin_stylescripts'));
     // Load front style sheet and JavaScript.
     add_action('wp_enqueue_scripts', array($this, 'enqueue_front_stylescripts'));
     // output tracking code
     add_action('wp_print_footer_scripts', array($this, 'print_front_scripts'));
     // Add partial completions
     add_action('wp_ajax_frmwks_push', array($this, 'tracker_push'));
     add_action('wp_ajax_nopriv_frmwks_push', array($this, 'tracker_push'));
     // open actions
     add_action('formworks_track', array($this, 'handle_track'), 10, 4);
     /**
      * Tracking
      */
     /** Caldera Forms */
     add_action('caldera_forms_submit_complete', function ($form) {
         do_action('formworks_track', 'caldera', $form['ID'], 'submission');
     });
     add_filter('caldera_forms_render_form', function ($html, $form) {
         $selector = array("name" => $form['name'], "selector" => "." . $form['ID'], "prefix" => 'caldera', "id" => $form['ID']);
         do_action('formworks_track', 'caldera', $form['ID'], 'loaded', $selector);
         return $html;
     }, 10, 2);
     /** JETPACK */
     add_filter('grunion_contact_form_success_message', function ($html) {
         if (isset($_GET['contact-form-id'])) {
             $form_id = $_GET['contact-form-id'];
             do_action('formworks_track', 'jp', $form_id, 'submission');
         }
         return $html;
     });
     add_filter('grunion_contact_form_form_action', function ($url, $post, $form) {
         $selector = array("name" => $post->post_title, "selector" => "#contact-form-" . $form);
         do_action('formworks_track', 'jp', $form, 'loaded', $selector);
         return $url;
     }, 15, 3);
     /** Formidable */
     add_action('frm_process_entry', function ($params) {
         do_action('formworks_track', 'frmid', $params['form_id'], 'submission');
     }, 15);
     add_filter('formidable_shortcode_atts', function ($shortcode_atts, $atts) {
         if (class_exists('\\FrmForm')) {
             $form = \FrmForm::getOne($atts['id']);
         }
         $selector = array("name" => $form->name, "selector" => "#form_" . $form->form_key);
         do_action('formworks_track', 'frmid', $form->id, 'loaded', $selector);
     }, 10, 2);
     /** Contact Form 7 */
     add_filter('wpcf7_form_elements', function ($html) {
         if (class_exists('\\WPCF7_ContactForm')) {
             $form = \WPCF7_ContactForm::get_current();
             do_action('formworks_track', 'cf7', $form->id(), 'loaded');
         }
         return $html;
     }, 10, 2);
     add_action('wpcf7_submit', function ($instance, $result) {
         if (isset($result['status']) && 'mail_sent' === $result['status']) {
             do_action('formworks_track', 'cf7', $instance->id(), 'submission');
         }
     }, 20, 2);
     /** Gravity Forms */
     add_filter('gform_get_form_filter', function ($html, $form) {
         $selector = array("name" => $form['title'], "selector" => "#gform_" . $form['id']);
         do_action('formworks_track', 'gform', $form['id'], 'loaded', $selector);
         return $html;
     }, 10, 2);
     add_action('gform_after_submission', function ($form) {
         // do a submission complete
         do_action('formworks_track', 'gform', $form['form_id'], 'submission');
         return;
     });
     /** Ninja Forms */
     add_action('ninja_forms_post_process', function () {
         global $ninja_forms_processing;
         if (is_object($ninja_forms_processing)) {
             do_action('formworks_track', 'ninja', $ninja_forms_processing->get_form_ID(), 'submission');
         }
     });
     //load settings class && licensing in admin
     if (is_admin()) {
         new settings();
         add_action('admin_init', function () {
             $plugin = frmwks_licensing_args();
             new \calderawp\licensing_helper\licensing($plugin);
         }, 0);
     }
 }
Exemplo n.º 2
0
/**
 * Display software licensing -- needs active, is active.
 *
 * @since 1.0.0
 *
 * @return string
 */
function frmwks_license_display()
{
    $plugin = frmwks_licensing_args();
    if (!function_exists('cwp_license_manager_register_licensed_product')) {
        $out[] = esc_html__('To activate or check the status of your FormWorks license, you must intall CalderaWP License Manager.', 'formworks');
        $out[] = sprintf('<p><a class="button button-secondary" href="%s" target="_blank">%s</a></p>', esc_url_raw(wp_nonce_url(self_admin_url('update.php?action=install-plugin&plugin=calderawp-license-manager'), 'install-plugin_calderawp-license-manager')), esc_html__('Install The License Manager', 'formworks'));
    } else {
        $active = cwp_license_manager_is_product_licensed($plugin['name']);
        if ($active) {
            $out[] = '<p style="border-left: 4px solid #46b450;background: white;display: inline;padding: 12px;">' . esc_html__('Your license is active', 'formworks') . '</p>';
        } elseif (!$active) {
            $out[] = sprintf('<a class="button button-secondary" href="%s" target="_blank">%s</a>', self_admin_url('options-general.php?page=calderawp_license_manager'), esc_html__('Please activate your FormWorks license using CalderaWP License Manager.', 'formworks'));
        }
    }
    return implode("\n", $out);
}