コード例 #1
0
ファイル: Helper.php プロジェクト: JSreactor/MarketCrater.com
 /**
  * @param $search
  * @param $replace
  * @param $subject
  * @return mixed
  */
 public static function str_replace($search, $replace, $subject)
 {
     if (is_array($subject)) {
         foreach ($subject as &$oneSubject) {
             $oneSubject = WPN_Helper::str_replace($search, $replace, $oneSubject);
         }
         unset($oneSubject);
         return $subject;
     } else {
         return str_replace($search, $replace, $subject);
     }
 }
コード例 #2
0
 /**
  * Get things rolling
  *
  * @since 2.7.4
  * @return void
  */
 function __construct()
 {
     //Bail if we aren't in the admin.
     if (!is_admin()) {
         return false;
     }
     if (!WPN_Helper::is_func_disabled('ignore_user_abort')) {
         ignore_user_abort(true);
     }
     //        if ( ! nf_is_func_disabled( 'set_time_limit' ) && ! ini_get( 'safe_mode' ) ) {
     //            //set_time_limit( 0 );
     //        }
     add_action('wp_ajax_nf_' . $this->action, array($this, 'processing'));
 }
コード例 #3
0
 public function __construct()
 {
     parent::__construct();
     $this->title = __('Query Strings', 'ninja-forms');
     $this->merge_tags = array('' => array('tag' => '{query_string_key}', 'label' => __('Query String', 'ninja_forms')));
     if (is_admin()) {
         return;
     }
     if (!is_array($_GET)) {
         return;
     }
     foreach ($_GET as $key => $value) {
         $value = WPN_Helper::get_query_string($key);
         $this->set_merge_tags($key, $value);
     }
 }
コード例 #4
0
 public static function export($form_id, array $sub_ids = array(), $return = FALSE)
 {
     //TODO: Set Date Format from Plugin Settings
     $date_format = 'm/d/Y';
     /*
      * Labels
      */
     $field_labels = array('_seq_num' => '#', '_date_submitted' => __('Date Submitted', 'ninja-forms'));
     // Legacy Filter from 2.9.*
     $field_labels = apply_filters('nf_subs_csv_label_array_before_fields', $field_labels, $sub_ids);
     $fields = Ninja_Forms()->form($form_id)->get_fields();
     $hidden_field_types = apply_filters('nf_sub_hidden_field_types', array());
     foreach ($fields as $field) {
         if (in_array($field->get_setting('type'), $hidden_field_types)) {
             continue;
         }
         $field_labels[$field->get_id()] = $field->get_setting('label');
     }
     /*
      * Submissions
      */
     $value_array = array();
     $subs = Ninja_Forms()->form($form_id)->get_subs();
     foreach ($subs as $sub) {
         if (!in_array($sub->get_id(), $sub_ids)) {
             continue;
         }
         $value['_seq_num'] = $sub->get_seq_num();
         $value['_date_submitted'] = $sub->get_sub_date($date_format);
         foreach ($field_labels as $field_id => $label) {
             if (!is_int($field_id)) {
                 continue;
             }
             $value[$field_id] = $sub->get_field_value($field_id);
         }
         $value_array[] = $value;
     }
     $value_array = WPN_Helper::stripslashes($value_array);
     // Legacy Filter from 2.9.*
     $value_array = apply_filters('nf_subs_csv_value_array', $value_array, $sub_ids);
     $csv_array[0][] = $field_labels;
     $csv_array[1][] = $value_array;
     $today = date($date_format, current_time('timestamp'));
     $filename = apply_filters('nf_subs_csv_filename', 'nf_subs_' . $today);
     $filename = $filename . ".csv";
     if ($return) {
         return WPN_Helper::str_putcsv($csv_array, apply_filters('nf_sub_csv_delimiter', ','), apply_filters('nf_sub_csv_enclosure', '"'), apply_filters('nf_sub_csv_terminator', "\n"));
     } else {
         header('Content-type: application/csv');
         header('Content-Disposition: attachment; filename="' . $filename . '"');
         header('Pragma: no-cache');
         header('Expires: 0');
         echo apply_filters('nf_sub_csv_bom', "");
         // Byte Order Mark
         echo WPN_Helper::str_putcsv($csv_array, apply_filters('nf_sub_csv_delimiter', ','), apply_filters('nf_sub_csv_enclosure', '"'), apply_filters('nf_sub_csv_terminator', "\n"));
         die;
     }
 }
コード例 #5
0
ファイル: Render.php プロジェクト: idies/escience-2016-wp
    public static function output_templates()
    {
        // Build File Path Hierarchy
        $file_paths = apply_filters('ninja_forms_field_template_file_paths', array(get_template_directory() . '/ninja-forms/templates/'));
        $file_paths[] = Ninja_Forms::$dir . 'includes/Templates/';
        // Search for and Output File Templates
        foreach (self::$loaded_templates as $file_name) {
            foreach ($file_paths as $path) {
                if (file_exists($path . "{$file_name}.html")) {
                    echo file_get_contents($path . "{$file_name}.html");
                    break;
                }
            }
        }
        ?>
        <script>
            var post_max_size = '<?php 
        echo WPN_Helper::string_to_bytes(ini_get('post_max_size'));
        ?>
';
            var upload_max_filesize = '<?php 
        echo WPN_Helper::string_to_bytes(ini_get('upload_max_filesize'));
        ?>
';
            var wp_memory_limit = '<?php 
        echo WPN_Helper::string_to_bytes(WP_MEMORY_LIMIT);
        ?>
';
        </script>
        <?php 
        // Action to Output Custom Templates
        do_action('ninja_forms_output_templates');
    }
コード例 #6
0
ファイル: Email.php プロジェクト: JSreactor/MarketCrater.com
 private function _create_csv($fields)
 {
     $csv_array = array();
     foreach ($fields as $field) {
         if (!isset($field['label'])) {
             continue;
         }
         $csv_array[0][] = $field['label'];
         $csv_array[1][] = WPN_Helper::stripslashes($field['value']);
     }
     $csv_content = WPN_Helper::str_putcsv($csv_array, apply_filters('ninja_forms_sub_csv_delimiter', ','), apply_filters('ninja_forms_sub_csv_enclosure', '"'), apply_filters('ninja_forms_sub_csv_terminator', "\n"));
     $upload_dir = wp_upload_dir();
     $path = trailingslashit($upload_dir['path']);
     // create temporary file
     $path = tempnam($path, 'Sub');
     $temp_file = fopen($path, 'r+');
     // write to temp file
     fwrite($temp_file, $csv_content);
     fclose($temp_file);
     // find the directory we will be using for the final file
     $path = pathinfo($path);
     $dir = $path['dirname'];
     $basename = $path['basename'];
     // create name for file
     $new_name = apply_filters('ninja_forms_submission_csv_name', 'ninja-forms-submission');
     // remove a file if it already exists
     if (file_exists($dir . '/' . $new_name . '.csv')) {
         unlink($dir . '/' . $new_name . '.csv');
     }
     // move file
     rename($dir . '/' . $basename, $dir . '/' . $new_name . '.csv');
     return $dir . '/' . $new_name . '.csv';
 }
コード例 #7
0
 public function export_listen()
 {
     // Bail if we aren't in the admin
     if (!is_admin()) {
         return false;
     }
     if (!isset($_REQUEST['form_id']) || empty($_REQUEST['form_id'])) {
         return false;
     }
     if (isset($_REQUEST['export_single']) && !empty($_REQUEST['export_single'])) {
         Ninja_Forms()->sub(esc_html($_REQUEST['export_single']))->export();
     }
     if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'export' || isset($_REQUEST['action2']) && $_REQUEST['action2'] == 'export') {
         $sub_ids = WPN_Helper::esc_html($_REQUEST['post']);
         Ninja_Forms()->form($_REQUEST['form_id'])->export_subs($sub_ids);
     }
     if (isset($_REQUEST['download_file']) && !empty($_REQUEST['download_file'])) {
         // Open our download all file
         $filename = esc_html($_REQUEST['download_file']);
         $upload_dir = wp_upload_dir();
         $file_path = trailingslashit($upload_dir['path']) . $filename . '.csv';
         if (file_exists($file_path)) {
             $myfile = file_get_contents($file_path);
         } else {
             $redirect = esc_url_raw(remove_query_arg(array('download_file', 'download_all')));
             wp_redirect($redirect);
             die;
         }
         unlink($file_path);
         $form_name = Ninja_Forms()->form(absint($_REQUEST['form_id']))->get_setting('title');
         $form_name = sanitize_title($form_name);
         $today = date('Y-m-d', current_time('timestamp'));
         $filename = apply_filters('ninja_forms_download_all_filename', $form_name . '-all-subs-' . $today);
         header('Content-type: application/csv');
         header('Content-Disposition: attachment; filename="' . $filename . '.csv"');
         header('Pragma: no-cache');
         header('Expires: 0');
         echo $myfile;
         die;
     }
 }
コード例 #8
0
ファイル: Form.php プロジェクト: JSreactor/MarketCrater.com
 public static function export($form_id, $return = FALSE)
 {
     //TODO: Set Date Format from Plugin Settings
     $date_format = 'm/d/Y';
     $form = Ninja_Forms()->form($form_id)->get();
     $export = array('settings' => $form->get_settings(), 'fields' => array(), 'actions' => array());
     $fields = Ninja_Forms()->form($form_id)->get_fields();
     foreach ($fields as $field) {
         $export['fields'][] = $field->get_settings();
     }
     $actions = Ninja_Forms()->form($form_id)->get_actions();
     foreach ($actions as $action) {
         $export['actions'][] = $action->get_settings();
     }
     if ($return) {
         return $export;
     } else {
         $today = date($date_format, current_time('timestamp'));
         $filename = apply_filters('ninja_forms_form_export_filename', 'nf_form_' . $today);
         $filename = $filename . ".nff";
         header('Content-type: application/json');
         header('Content-Disposition: attachment; filename="' . $filename . '"');
         header('Pragma: no-cache');
         header('Expires: 0');
         //            echo apply_filters( 'ninja_forms_form_export_bom',"\xEF\xBB\xBF" ) ; // Byte Order Mark
         echo json_encode(WPN_Helper::utf8_encode($export));
         die;
     }
 }
コード例 #9
0
function nf_is_func_disabled($function)
{
    Ninja_Forms::deprecated_notice('nf_is_func_disabled', '3.0', 'WPN_Helper::is_func_disabled()', debug_backtrace());
    return WPN_Helper::is_func_disabled($function);
}