public static function enqueue_css($register = 'enqueue') { global $frm_vars; $register_css = $register == 'register'; if (($frm_vars['load_css'] || $register_css) && !FrmAppHelper::is_admin()) { $frm_settings = FrmAppHelper::get_settings(); if ($frm_settings->load_style == 'none') { return; } $css = apply_filters('get_frm_stylesheet', self::custom_stylesheet()); if (!empty($css)) { $version = FrmAppHelper::plugin_version(); foreach ((array) $css as $css_key => $file) { if ($register == 'register') { wp_register_style($css_key, $file, array(), $version); } if ('all' == $frm_settings->load_style || $register != 'register') { wp_enqueue_style($css_key); } unset($css_key, $file); } if ($frm_settings->load_style == 'all') { $frm_vars['css_loaded'] = true; } } unset($css); } }
public static function enqueue_jquery_css() { $theme_css = FrmStylesController::get_style_val('theme_css'); if ($theme_css != -1) { wp_enqueue_style('jquery-theme', self::jquery_css_url($theme_css), array(), FrmAppHelper::plugin_version()); } }
/** * @covers FrmAppHelper::plugin_version */ function test_plugin_version() { $version = FrmAppHelper::plugin_version(); $this->assertNotEmpty($version); $plugin_data = get_plugin_data(dirname(__FILE__) . '/../formidable.php'); $expected_version = $plugin_data['Version']; $this->assertEquals($version, $expected_version); }
function FrmCptUpdate() { if (!class_exists('FrmUpdatesController') and !class_exists('FrmUpdate')) { return; } // Where all the vitals are defined for this plugin $this->plugin_nicename = 'formidable-math-captcha'; $this->plugin_name = 'formidable-math-captcha/formidable-math-captcha.php'; $this->pro_last_checked_store = 'frmcpt_last_check'; $this->pro_check_interval = 60 * 60 * 24; // Checking every 24 hours add_filter('site_transient_update_plugins', array(&$this, 'queue_update')); if (method_exists('FrmAppHelper', 'plugin_version')) { $this->version = FrmAppHelper::plugin_version(); } else { global $frm_version; $this->version = $frm_version; } if (version_compare($this->version, '1.07.0rc1', '<')) { add_filter('pre_set_site_transient_update_plugins', array(&$this, 'queue_old_update')); } //Deprecated }
public static function admin_js() { $version = FrmAppHelper::plugin_version(); FrmAppHelper::load_admin_wide_js(false); wp_register_script('formidable_admin', FrmAppHelper::plugin_url() . '/js/formidable_admin.js', array('formidable_admin_global', 'formidable', 'jquery', 'jquery-ui-core', 'jquery-ui-draggable', 'jquery-ui-sortable', 'bootstrap_tooltip', 'bootstrap-multiselect'), $version, true); wp_register_style('formidable-admin', FrmAppHelper::plugin_url() . '/css/frm_admin.css', array(), $version); wp_register_script('bootstrap_tooltip', FrmAppHelper::plugin_url() . '/js/bootstrap.min.js', array('jquery'), '3.3.4'); // load multselect js wp_register_script('bootstrap-multiselect', FrmAppHelper::plugin_url() . '/js/bootstrap-multiselect.js', array('jquery', 'bootstrap_tooltip'), '0.9.8', true); $page = FrmAppHelper::simple_get('page', 'sanitize_title'); $post_type = FrmAppHelper::simple_get('post_type', 'sanitize_title'); global $pagenow; if (strpos($page, 'formidable') === 0 || $pagenow == 'edit.php' && $post_type == 'frm_display') { wp_enqueue_script('admin-widgets'); wp_enqueue_style('widgets'); wp_enqueue_script('formidable'); wp_enqueue_script('formidable_admin'); FrmAppHelper::localize_script('admin'); wp_enqueue_style('formidable-admin'); add_thickbox(); wp_register_script('formidable-editinplace', FrmAppHelper::plugin_url() . '/js/jquery/jquery.editinplace.packed.js', array('jquery'), '2.3.0'); } else { if ($pagenow == 'post.php' || $pagenow == 'post-new.php' && $post_type == 'frm_display') { if (isset($_REQUEST['post_type'])) { $post_type = sanitize_title($_REQUEST['post_type']); } else { if (isset($_REQUEST['post']) && absint($_REQUEST['post'])) { $post = get_post(absint($_REQUEST['post'])); if (!$post) { return; } $post_type = $post->post_type; } else { return; } } if ($post_type == 'frm_display') { wp_enqueue_script('jquery-ui-draggable'); wp_enqueue_script('formidable_admin'); wp_enqueue_style('formidable-admin'); FrmAppHelper::localize_script('admin'); } } else { if ($pagenow == 'widgets.php') { FrmAppHelper::load_admin_wide_js(); } } } }
/** * Load the JS file on non-Formidable pages in the admin area * @since 2.0 */ public static function load_admin_wide_js($load = true) { $version = FrmAppHelper::plugin_version(); wp_register_script('formidable_admin_global', FrmAppHelper::plugin_url() . '/js/formidable_admin_global.js', array('jquery'), $version); wp_localize_script('formidable_admin_global', 'frmGlobal', array('updating_msg' => __('Please wait while your site updates.', 'formidable'), 'deauthorize' => __('Are you sure you want to deauthorize Formidable Forms on this site?', 'formidable'), 'url' => FrmAppHelper::plugin_url(), 'loading' => __('Loading…'), 'nonce' => wp_create_nonce('frm_ajax'))); if ($load) { wp_enqueue_script('formidable_admin_global'); } }
public static function is_formidable_supported($version) { if (!class_exists('FrmProDisplay')) { return false; } global $frm_version; if ($frm_version) { /** * Get the plugin version when < 2.0 */ $current_frm_version = $frm_version; } else { if (is_callable('FrmAppHelper::plugin_version')) { /** * Get the plugin version when > 2.0 */ $current_frm_version = FrmAppHelper::plugin_version(); } } if (version_compare($current_frm_version, $version, '>=') === true) { global $frmpro_is_installed; if ($frmpro_is_installed) { return true; } /** * Check if pro is installed in 2.0+ */ return is_callable('FrmAppHelper::pro_is_installed') && FrmAppHelper::pro_is_installed(); } return false; }
public static function front_head() { global $frm_settings; if (is_multisite()) { global $frm_vars; $old_db_version = get_option('frm_db_version'); $pro_db_version = $frm_vars['pro_is_installed'] ? get_option('frmpro_db_version') : false; if ((int) $old_db_version < (int) FrmAppHelper::$db_version || $frm_vars['pro_is_installed'] && (int) $pro_db_version < (int) FrmAppHelper::$pro_db_version) { self::install($old_db_version); } } $version = FrmAppHelper::plugin_version(); wp_register_script('formidable', FrmAppHelper::plugin_url() . '/js/formidable.min.js', array('jquery'), $version, true); wp_register_script('jquery-placeholder', FrmAppHelper::plugin_url() . '/js/jquery/jquery.placeholder.js', array('jquery'), '2.0.7', true); wp_register_script('recaptcha-ajax', 'http' . (is_ssl() ? 's' : '') . '://www.google.com/recaptcha/api/js/recaptcha_ajax.js', '', true); if (is_admin() && !defined('DOING_AJAX')) { // don't load this in back-end return; } self::localize_script('front'); wp_enqueue_script('jquery'); $style = apply_filters('get_frm_stylesheet', array('frm-forms' => FrmAppHelper::plugin_url() . '/css/frm_display.css')); if ($style) { foreach ((array) $style as $k => $file) { wp_register_style($k, $file, array(), $version); if ('all' == $frm_settings->load_style) { wp_enqueue_style($k); } unset($k, $file); } } unset($style); if ($frm_settings->load_style == 'all') { global $frm_vars; $frm_vars['css_loaded'] = true; } }
public static function front_head() { $version = FrmAppHelper::plugin_version(); $suffix = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min'; wp_register_script('formidable', FrmAppHelper::plugin_url() . "/js/formidable{$suffix}.js", array('jquery'), $version, true); wp_register_script('jquery-placeholder', FrmAppHelper::plugin_url() . '/js/jquery/jquery.placeholder.js', array('jquery'), '2.0.7', true); if (FrmAppHelper::is_admin()) { // don't load this in back-end return; } FrmAppHelper::localize_script('front'); FrmStylesController::enqueue_css('register'); }
public static function register_scripts() { global $wp_scripts, $frmpro_settings, $frm_settings; wp_register_script('jquery-frm-rating', FrmAppHelper::plugin_url() . '/pro/js/jquery.rating.min.js', array('jquery'), '4.11', true); wp_register_script('jquery-maskedinput', FrmAppHelper::plugin_url() . '/pro/js/jquery.maskedinput.min.js', array('jquery'), '1.3', true); wp_register_script('nicedit', FrmAppHelper::plugin_url() . '/pro/js/nicedit.js', array(), '1', true); if ($frmpro_settings->theme_css != -1) { wp_register_style('jquery-theme', FrmProAppHelper::jquery_css_url($frmpro_settings->theme_css), array(), FrmAppHelper::plugin_version()); } wp_register_script('jquery-chosen', FrmAppHelper::plugin_url() . '/pro/js/chosen.jquery.min.js', array('jquery'), '1.1.0', true); //jquery-ui-datepicker registered in WP 3.3 if (!isset($wp_scripts->registered) or !isset($wp_scripts->registered['jquery-ui-datepicker'])) { $date_ver = FrmProAppHelper::datepicker_version(); wp_register_script('jquery-ui-datepicker', FrmAppHelper::plugin_url() . '/pro/js/jquery.ui.datepicker' . $date_ver . '.js', array('jquery', 'jquery-ui-core'), empty($date_ver) ? '1.8.16' : trim($date_ver, '.'), true); } if ($frm_settings->accordion_js and (!isset($wp_scripts->registered) or !isset($wp_scripts->registered['jquery-ui-accordion']))) { wp_register_script('jquery-ui-accordion', FrmAppHelper::plugin_url() . '/pro/js/jquery.ui.accordion.js', array('jquery', 'jquery-ui-core'), '1.8.16', true); } }
function send_mothership_request($endpoint, $args = array(), $domain = false) { if (empty($domain)) { $domain = $this->pro_mothership; } $uri = "{$domain}{$endpoint}"; $arg_array = array('body' => $args, 'timeout' => $this->timeout, 'sslverify' => false, 'user-agent' => 'Formidable/' . FrmAppHelper::plugin_version() . '; ' . get_bloginfo('url')); $resp = wp_remote_post($uri, $arg_array); $body = wp_remote_retrieve_body($resp); if (is_wp_error($resp)) { $message = sprintf(__('You had an error communicating with Strategy11\'s API. %1$sClick here%2$s for more information.', 'formidable'), '<a href="http://formidablepro.com/knowledgebase/why-cant-i-activate-formidable-pro/" target="_blank">', '</a>'); if (is_wp_error($resp)) { $message .= ' ' . $resp->get_error_message(); } return $message; } else { if ($body == 'error' || is_wp_error($body)) { return __('You had an HTTP error connecting to Strategy11\'s API', 'formidable'); } else { if (null !== ($json_res = json_decode($body, true))) { if (is_array($json_res) && isset($json_res['error'])) { return $json_res['error']; } else { return $json_res; } } else { if (isset($resp['response']) && isset($resp['response']['code'])) { return sprintf(__('There was a %1$s error: %2$s', 'formidable'), $resp['response']['code'], $resp['response']['message'] . ' ' . $resp['body']); } else { return __('Your License Key was invalid', 'formidable'); } } } } return false; }
<?php // 1.07.02 define('FRM_PATH', dirname(__FILE__)); global $frm_siteurl; //deprecated: use FrmAppHelper::site_url() $frm_siteurl = site_url(); if (is_ssl() and (!preg_match('/^https:\\/\\/.*\\..*$/', $frm_siteurl) or !preg_match('/^https:\\/\\/.*\\..*$/', WP_PLUGIN_URL))) { $frm_siteurl = str_replace('http://', 'https://', $frm_siteurl); define('FRM_URL', str_replace('http://', 'https://', WP_PLUGIN_URL . '/formidable')); } else { define('FRM_URL', WP_PLUGIN_URL . '/formidable'); //deprecated: use FrmAppHelper::plugin_url() } global $frm_version, $frm_ajax_url; $frm_version = FrmAppHelper::plugin_version(); //deprecated: use FrmAppHelper::plugin_version() $frm_ajax_url = admin_url('admin-ajax.php'); global $frmpro_is_installed; $frmpro_is_installed = FrmAppController::pro_is_installed(); // 1.07.05 if (class_exists('FrmProEntry')) { global $frmpro_entry; global $frmpro_entry_meta; global $frmpro_field; global $frmpro_form; $frmpro_entry = new FrmProEntry(); $frmpro_entry_meta = new FrmProEntryMeta(); $frmpro_field = new FrmProField(); $frmpro_form = new FrmProForm(); new FrmProDb();