Esempio n. 1
0
 public static function enqueue_form_scripts($form_id, $is_ajax = false)
 {
     require_once GFCommon::get_base_path() . '/form_display.php';
     $form = RGFormsModel::get_form_meta($form_id);
     GFFormDisplay::enqueue_form_scripts($form, $is_ajax);
     $addons = GFAddOn::get_registered_addons();
     foreach ($addons as $addon) {
         $a = call_user_func(array($addon, 'get_instance'));
         $a->enqueue_scripts($form, $is_ajax);
     }
 }
 /**
  * Force Gravity Forms to output scripts as if it were in the admin
  * @return void
  */
 function print_scripts()
 {
     $gravityview_view = GravityView_View::getInstance();
     wp_register_script('gform_gravityforms', GFCommon::get_base_url() . '/js/gravityforms.js', array('jquery', 'gform_json', 'gform_placeholder', 'sack', 'plupload-all', 'gravityview-fe-view'));
     GFFormDisplay::enqueue_form_scripts($gravityview_view->getForm(), false);
     // Sack is required for images
     wp_print_scripts(array('sack', 'gform_gravityforms'));
 }
function gravity_form_enqueue_scripts($form_id, $is_ajax = false)
{
    if (!is_admin()) {
        require_once GFCommon::get_base_path() . "/form_display.php";
        $form = RGFormsModel::get_form_meta($form_id);
        GFFormDisplay::enqueue_form_scripts($form, $is_ajax);
    }
}
 public static function gform_do_shortcode($content)
 {
     $is_ajax = false;
     $forms = GFFormDisplay::get_embedded_forms($content, $is_ajax);
     foreach ($forms as $form) {
         if (headers_sent()) {
             GFFormDisplay::print_form_scripts($form, $is_ajax);
         } else {
             GFFormDisplay::enqueue_form_scripts($form, $is_ajax);
         }
     }
     return do_shortcode($content);
 }
Esempio n. 5
0
        <link rel='stylesheet' href='<?php 
echo GFCommon::get_base_url();
?>
/css/reset.css' type='text/css' />
        <link rel='stylesheet' href='<?php 
echo GFCommon::get_base_url();
?>
/css/forms.css' type='text/css' />
        <link rel='stylesheet' href='<?php 
echo GFCommon::get_base_url();
?>
/css/preview.css' type='text/css' />
        <?php 
require_once GFCommon::get_base_path() . "/form_display.php";
$form = RGFormsModel::get_form_meta($_GET["id"]);
GFFormDisplay::enqueue_form_scripts($form);
wp_print_scripts();
$styles = apply_filters("gform_preview_styles", false, $form);
if (!empty($styles)) {
    wp_print_styles($styles);
}
?>

    </head>
    <body>
    <div id="preview_top">
	    <div id="preview_hdr">
		    <div><span class="actionlinks"><a href="javascript:window.close()" class="close_window"><?php 
_e("close window", "gravityforms");
?>
</a></span><?php 
Esempio n. 6
0
 public static function gform_do_shortcode($content)
 {
     $is_ajax = false;
     $forms = GFFormDisplay::get_embedded_forms($content, $is_ajax);
     foreach ($forms as $form) {
         /**
          * Determine if scripts and stylesheets should be printed or enqueued when processing form shortcodes after headers have been sent.
          *
          * @since 2.0
          *
          * @param bool $disable_print_form_script Defaults to false.
          * @param array $form The form object for the shortcode being processed.
          * @param bool $is_ajax Indicates if ajax was enabled on the shortcode.
          */
         $disable_print_form_script = apply_filters('gform_disable_print_form_scripts', false, $form, $is_ajax);
         if (headers_sent() && !$disable_print_form_script) {
             GFFormDisplay::print_form_scripts($form, $is_ajax);
         } else {
             GFFormDisplay::enqueue_form_scripts($form, $is_ajax);
         }
     }
     return do_shortcode($content);
 }
 public static function initialise_form_edit()
 {
     /*
      * If we aren't editing our form, don't do anything
      */
     if (empty($_GET['action']) || empty($_GET['lid']) || !is_user_logged_in()) {
         return false;
     }
     $lid = isset($_GET['lid']) ? (int) $_GET['lid'] : 0;
     self::$lead = $lead = GFAPI::get_entry($lid);
     self::$form = $form = GFAPI::get_form(self::$lead['form_id']);
     if (!self::check_user_permission(self::$lead)) {
         return false;
     }
     self::$allowed_edit = true;
     if (!class_exists('GFFormDisplay')) {
         require_once GFCommon::get_base_path() . "/form_display.php";
     }
     $field_values = RGForms::post("gform_field_values");
     /*
      * Include appropriate css/javascript here...
      */
     GFFormDisplay::enqueue_form_scripts($form, false);
     GFFormDisplay::add_init_script($form["id"], "conditional_logic", GFFormDisplay::ON_PAGE_RENDER, self::get_conditional_logic($form, $field_values));
     GFFormDisplay::add_init_script($form["id"], "pricing", GFFormDisplay::ON_PAGE_RENDER, GFFormDisplay::get_pricing_init_script($form));
     $chosen_script = GFFormDisplay::get_chosen_init_script($form);
     GFFormDisplay::add_init_script($form["id"], "chosen", GFFormDisplay::ON_PAGE_RENDER, $chosen_script);
     GFFormDisplay::add_init_script($form["id"], "chosen", GFFormDisplay::ON_CONDITIONAL_LOGIC, $chosen_script);
     GFFormDisplay::add_init_script($form['id'], 'input_mask', GFFormDisplay::ON_PAGE_RENDER, GFFormDisplay::get_input_mask_init_script($form));
     GFFormDisplay::add_init_script($form['id'], 'calculation', GFFormDisplay::ON_PAGE_RENDER, GFFormDisplay::get_calculations_init_script($form));
     GFFormDisplay::add_init_script($form['id'], 'currency_format', GFFormDisplay::ON_PAGE_RENDER, GFFormDisplay::get_currency_format_init_script($form));
     return true;
 }
 public function enqueue_form_scripts()
 {
     $form = $this->get_current_form();
     if (empty($form)) {
         return;
     }
     require_once GFCommon::get_base_path() . '/form_display.php';
     if ($this->has_enhanced_dropdown($form)) {
         if (wp_script_is('chosen', 'registered')) {
             wp_enqueue_script('chosen');
         } else {
             wp_enqueue_script('gform_chosen');
         }
     }
     GFFormDisplay::enqueue_form_scripts($form);
 }