当前位置: 首页>>代码示例>>PHP>>正文


PHP Ninja_Forms函数代码示例

本文整理汇总了PHP中Ninja_Forms函数的典型用法代码示例。如果您正苦于以下问题:PHP Ninja_Forms函数的具体用法?PHP Ninja_Forms怎么用?PHP Ninja_Forms使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了Ninja_Forms函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: display_form_front_end

 public function display_form_front_end(array $atts = array())
 {
     if (!isset($atts['id'])) {
         return;
     }
     ob_start();
     Ninja_Forms()->display($atts['id']);
     return ob_get_clean();
 }
开发者ID:kjohnson,项目名称:3.0-commits-io,代码行数:9,代码来源:Shortcodes.php

示例2: nf_csv_attachment

function nf_csv_attachment($sub_id)
{
    global $ninja_forms_processing;
    // make sure this form is supposed to attach a CSV
    if (1 == $ninja_forms_processing->get_form_setting('admin_attach_csv') and 'submit' == $ninja_forms_processing->get_action()) {
        // create CSV content
        $csv_content = Ninja_Forms()->sub($sub_id)->export(true);
        $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');
        $file1 = $dir . '/' . $new_name . '.csv';
        // add new file to array of existing files
        $files = $ninja_forms_processing->get_form_setting('admin_attachments');
        array_push($files, $file1);
        $ninja_forms_processing->update_form_setting('admin_attachments', $files);
        $ninja_forms_processing->update_extra_value('_attachment_csv_path', $file1);
    }
}
开发者ID:USSLomaPrieta,项目名称:usslomaprieta.org,代码行数:35,代码来源:attachment-csv.php

示例3: process

 /**
  * Process our Push notification
  *
  * @access public
  * @since  0.0.1
  * @return void
  */
 public function process($id)
 {
     $form_id = $id ? Ninja_Forms()->notification($id)->form_id : '';
     $api_key = Ninja_Forms()->notification($id)->get_setting('api_key');
     $list_id = Ninja_Forms()->notification($id)->get_setting('list_id');
     $email = $this->process_setting($id, 'email');
     if (empty($api_key) || empty($list_id) || empty($email)) {
         //file_put_contents('/tmp/notifications-pushbullet-class.log', "Empty access token\n", FILE_APPEND);
         return;
     }
     $first_name = $this->process_setting($id, 'first_name');
     $last_name = $this->process_setting($id, 'last_name');
     $merge_fields = array();
     if ($first_name) {
         $merge_fields['FNAME'] = $first_name;
     }
     if ($last_name) {
         $merge_fields['LNAME'] = $last_name;
     }
     $mc = new MailChimp($api_key);
     $added = $mc->post("lists/{$list_id}/members", array('email_address' => $email, 'status' => 'subscribed', 'merge_fields' => $merge_fields));
     if ($added) {
         //
     } else {
         // Could be SSL-verify of cURL that fails...
     }
 }
开发者ID:bjrnqprs,项目名称:ninja-forms-mailchimp-subscribe,代码行数:34,代码来源:plugin.php

示例4: ninja_forms_preview_link

function ninja_forms_preview_link($form_id = '', $echo = true)
{
    if ($form_id == '') {
        if (isset($_REQUEST['form_id'])) {
            $form_id = absint($_REQUEST['form_id']);
        } else {
            $form_id = '';
        }
    }
    $base = home_url();
    $form_data = ninja_forms_get_form_by_id($form_id);
    $append_page = Ninja_Forms()->form($form_id)->get_setting('append_page');
    if (empty($append_page)) {
        $opt = nf_get_settings();
        if (isset($opt['preview_id'])) {
            $page_id = $opt['preview_id'];
        } else {
            $page_id = '';
        }
    } else {
        $page_id = $append_page;
    }
    if ($echo) {
        $preview_link = '<a target="_blank" href="' . $base . '/?page_id=' . $page_id . '&preview=true&form_id=' . $form_id . '">' . __('Preview Form', 'ninja-forms') . '</a>';
    } else {
        $preview_link = $base . '/?page_id=' . $page_id . '&preview=true&form_id=' . $form_id;
    }
    return $preview_link;
}
开发者ID:thehereward,项目名称:ninja-forms,代码行数:29,代码来源:form-preview.php

示例5: ninja_forms_export_form

function ninja_forms_export_form($form_id)
{
    if ($form_id == '') {
        return;
    }
    $plugin_settings = nf_get_settings();
    $form_title = Ninja_Forms()->form($form_id)->get_setting('form_title');
    $form_row = ninja_forms_serialize_form($form_id);
    $form_title = preg_replace('/[^a-zA-Z0-9-]/', '', $form_title);
    $form_title = str_replace(" ", "-", $form_title);
    if (isset($plugin_settings['date_format'])) {
        $date_format = $plugin_settings['date_format'];
    } else {
        $date_format = 'm/d/Y';
    }
    //$today = date($date_format);
    $current_time = current_time('timestamp');
    $today = date($date_format, $current_time);
    header("Content-type: application/csv");
    header('Content-Disposition: attachment; filename="' . $form_title . '"-"' . $today . '".nff"');
    header("Pragma: no-cache");
    header("Expires: 0");
    echo $form_row;
    die;
}
开发者ID:ramiy,项目名称:ninja-forms,代码行数:25,代码来源:impexp-forms.php

示例6: process

 public function process($action_settings, $form_id, $data)
 {
     if (isset($data['settings']['is_preview']) && $data['settings']['is_preview']) {
         return $data;
     }
     if (!apply_filters('ninja_forms_save_submission', true, $form_id)) {
         return $data;
     }
     $sub = Ninja_Forms()->form($form_id)->sub()->get();
     $hidden_field_types = apply_filters('nf_sub_hidden_field_types', array());
     foreach ($data['fields'] as $field) {
         if (in_array($field['type'], array_values($hidden_field_types))) {
             $data['actions']['save']['hidden'][] = $field['type'];
             continue;
         }
         $field['value'] = apply_filters('nf_save_sub_user_value', $field['value'], $field['id']);
         $sub->update_field_value($field['id'], $field['value']);
     }
     if (isset($data['extra'])) {
         $sub->update_extra_values($data['extra']);
     }
     do_action('nf_before_save_sub', $sub->get_id());
     $sub->save();
     do_action('nf_save_sub', $sub->get_id());
     do_action('nf_create_sub', $sub->get_id());
     do_action('ninja_forms_save_sub', $sub->get_id());
     $data['actions']['save']['sub_id'] = $sub->get_id();
     return $data;
 }
开发者ID:JSreactor,项目名称:MarketCrater.com,代码行数:29,代码来源:Save.php

示例7: step

 public function step()
 {
     $exported_subs = get_user_option(get_current_user_id(), 'nf_download_all_subs_ids');
     if (!is_array($exported_subs)) {
         $exported_subs = array();
     }
     $previous_name = get_user_option(get_current_user_id(), 'nf_download_all_subs_filename');
     if ($previous_name) {
         $this->args['filename'] = $previous_name;
     }
     $args = array('posts_per_page' => 250, 'paged' => $this->step, 'post_type' => 'nf_sub', 'meta_query' => array(array('key' => '_form_id', 'value' => $this->args['form_id'])));
     $subs_results = get_posts($args);
     if (is_array($subs_results) && !empty($subs_results)) {
         $upload_dir = wp_upload_dir();
         $file_path = trailingslashit($upload_dir['path']) . $this->args['filename'] . '.csv';
         $myfile = fopen($file_path, 'a') or die('Unable to open file!');
         $x = 0;
         $export = '';
         foreach ($subs_results as $sub) {
             $sub_export = Ninja_Forms()->sub($sub->ID)->export(true);
             if ($x > 0 || $this->step > 1) {
                 $sub_export = substr($sub_export, strpos($sub_export, "\n") + 1);
             }
             if (!in_array($sub->ID, $exported_subs)) {
                 $export .= $sub_export;
                 $exported_subs[] = $sub->ID;
             }
             $x++;
         }
         fwrite($myfile, $export);
         fclose($myfile);
     }
     update_user_option(get_current_user_id(), 'nf_download_all_subs_ids', $exported_subs);
 }
开发者ID:umairakhtar123,项目名称:hova,代码行数:34,代码来源:download-all-subs.php

示例8: nf_not_logged_in_msg

/**
 * Adds our not logged-in message if the user is not logged-in and the form requires the user to be logged-in.
 *
 * @since 2.9
 * @return void
 */
function nf_not_logged_in_msg($form_id)
{
    $not_logged_in = Ninja_Forms()->form($form_id)->get_setting('logged_in');
    if (!is_user_logged_in() && 1 == $not_logged_in) {
        echo Ninja_Forms()->form($form_id)->get_setting('not_logged_in_msg');
    }
}
开发者ID:ramiy,项目名称:ninja-forms,代码行数:13,代码来源:not-logged-in.php

示例9: nf_fu_upgrade_settings

/**
 * Update the "attach file to this email" settings on any "Admin" email notifications we may have.
 *
 * @since 1.3.8
 * @return void
*/
function nf_fu_upgrade_settings()
{
    // Check to see if we've already done this.
    $updated = get_option('nf_convert_upload_settings_complete', false);
    if ($updated || version_compare(NINJA_FORMS_VERSION, '2.8', '<')) {
        return;
    }
    $notifications = nf_get_all_notifications();
    // Make sure that there are some notifications.
    if (!is_array($notifications)) {
        return;
    }
    // Loop through our notifications and see if any of them were "admin emails"
    foreach ($notifications as $n) {
        if (Ninja_Forms()->notification($n['id'])->get_setting('admin_email')) {
            // Grab our form id so that we can loop over our fields.
            $form_id = Ninja_Forms()->notification($n['id'])->form_id;
            // Loop over our form fields. If we find an upload field, see if the option is checked.
            foreach (Ninja_Forms()->form($form_id)->fields as $field_id => $field) {
                if ('_upload' == $field['type'] && isset($field['data']['email_attachment']) && $field['data']['email_attachment'] == 1) {
                    Ninja_Forms()->notification($n['id'])->update_setting('file_upload_' . $field_id, 1);
                }
            }
        }
    }
    update_option('nf_convert_upload_settings_complete', true);
}
开发者ID:pjsinco,项目名称:doctorsthatdo-wp-content,代码行数:33,代码来源:upgrade-functions.php

示例10: notification_type

 /**
  * Function that registers a notification type
  * 
  * @access public
  * @param string $slug - Notification type slug. Must be unique.
  * @param string $classname - Name of the class that should be used for the notification type.
  * @since 3.0
  * @return void
  */
 public function notification_type($slug, $nicename, $classname)
 {
     if (!empty($slug) && !empty($classname) && !isset(Ninja_Forms()->registered_field_types[$slug])) {
         Ninja_Forms()->registered_notification_types[$slug]['nicename'] = $nicename;
         Ninja_Forms()->registered_notification_types[$slug]['classname'] = $classname;
     }
 }
开发者ID:serker72,项目名称:T3S,代码行数:16,代码来源:register.php

示例11: maybe_delete

 /**
  * Delete a form if it is created and not saved within 24 hrs.
  * 
  * @access public
  * @since 2.9
  * @return void
  */
 public function maybe_delete($form_id)
 {
     $status = Ninja_Forms()->form($form_id)->get_setting('status');
     if ('new' == $status) {
         Ninja_Forms()->form($form_id)->delete();
     }
 }
开发者ID:ramiy,项目名称:ninja-forms,代码行数:14,代码来源:forms.php

示例12: ninja_forms_get_form_by_sub_id

function ninja_forms_get_form_by_sub_id($sub_id)
{
    global $wpdb;
    $form_id = Ninja_Forms()->sub($sub_id)->form_id;
    $form_row = ninja_forms_get_form_by_id($form_id);
    return $form_row;
}
开发者ID:se7ven214,项目名称:Kungfuphp.local,代码行数:7,代码来源:database.php

示例13: process

    /**
     * Process
     *
     * @param string $id
     * @return void
     */
    public function process($id)
    {
        global $ninja_forms_processing;
        $form_id = $ninja_forms_processing->get_form_ID();
        $form_title = $ninja_forms_processing->get_form_setting('form_title');
        $all_fields = ninja_forms_get_fields_by_form_id($form_id);
        $total = '';
        // Get IDs of fields that are to be sent to PayPal
        $accepted_fields = $PayPalEmail = Ninja_Forms()->notification($id)->get_setting('accepted_fields');
        $accepted_ary = explode(',', $accepted_fields);
        if (is_array($all_fields)) {
            foreach ($all_fields as $field) {
                $value = $ninja_forms_processing->get_field_value($field['id']);
                if (in_array($field['id'], $accepted_ary)) {
                    $total += $value;
                }
            }
        }
        // Grab PayPal email from NF setting
        $paypal_email = Ninja_Forms()->notification($id)->get_setting('paypal_email');
        // Format PayPal URL
        $url = 'https://www.paypal.com/us/cgi-bin/webscr?cmd=_xclick
		&business=' . urlencode($paypal_email) . '
		&item_name=' . urlencode($form_title) . '
		&item_number=
		&amount=' . $total . '
		&no_shipping=1
		&return=' . site_url() . '
		&currency_code=USD&lc=US&bn=PP-BuyNowBF';
        // Do the redirection to PayPal
        wp_redirect($url);
        exit;
    }
开发者ID:trevanhetzel,项目名称:ninja-forms-paypal-redirect,代码行数:39,代码来源:paypal-redirect.php

示例14: create_form

 /**
  * Creates a Form
  *
  * ## OPTIONS
  *
  * <title>
  * : The form title.
  *
  * ## EXAMPLES
  *
  *     wp ninja-forms form "My New Form"
  *
  * @synopsis <title>
  * @subcommand form
  * @alias create-form
  */
 public function create_form($args, $assoc_args)
 {
     list($title) = $args;
     $form = Ninja_Forms()->form()->get();
     $form->update_setting('title', $title);
     $form->save();
 }
开发者ID:kjohnson,项目名称:3.0-commits-io,代码行数:23,代码来源:NinjaFormsCommand.php

示例15: ninja_forms_session_class_setup

function ninja_forms_session_class_setup()
{
    $cache = Ninja_Forms()->session->get('nf_cache');
    if ($cache && !is_admin()) {
        add_action('init', 'ninja_forms_setup_processing_class', 5);
    }
}
开发者ID:idies,项目名称:escience-2016-wp,代码行数:7,代码来源:display-form.php


注:本文中的Ninja_Forms函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。