Ejemplo n.º 1
0
 public static function get_template($args = '')
 {
     global $l10n;
     $defaults = array('locale' => null, 'title' => '');
     $args = wp_parse_args($args, $defaults);
     $locale = $args['locale'];
     $title = $args['title'];
     if ($locale) {
         $mo_orig = $l10n['contact-form-7'];
         wpcf7_load_textdomain($locale);
     }
     self::$current = $contact_form = new self();
     $contact_form->title = $title ? $title : __('Untitled', 'contact-form-7');
     $contact_form->locale = $locale ? $locale : get_locale();
     $properties = $contact_form->get_properties();
     foreach ($properties as $key => $value) {
         $properties[$key] = WPCF7_ContactFormTemplate::get_default($key);
     }
     $contact_form->properties = $properties;
     $contact_form = apply_filters('wpcf7_contact_form_default_pack', $contact_form, $args);
     if (isset($mo_orig)) {
         $l10n['contact-form-7'] = $mo_orig;
     }
     return $contact_form;
 }
Ejemplo n.º 2
0
function wpcf7_install()
{
    if ($opt = get_option('wpcf7')) {
        return;
    }
    wpcf7_load_textdomain();
    wpcf7_register_post_types();
    wpcf7_upgrade();
    if (get_posts(array('post_type' => 'wpcf7_contact_form'))) {
        return;
    }
    $contact_form = WPCF7_ContactForm::get_template(array('title' => sprintf(__('Contact form %d', 'contact-form-7'), 1)));
    $contact_form->save();
}
Ejemplo n.º 3
0
 public static function generate_default_package($args = '')
 {
     global $l10n;
     $defaults = array('locale' => null, 'title' => '');
     $args = wp_parse_args($args, $defaults);
     $locale = $args['locale'];
     $title = $args['title'];
     if ($locale) {
         $mo_orig = $l10n['contact-form-7'];
         wpcf7_load_textdomain($locale);
     }
     $contact_form = new self();
     $contact_form->initial = true;
     $contact_form->title = $title ? $title : __('Untitled', 'contact-form-7');
     $contact_form->locale = $locale ? $locale : get_locale();
     $props = $contact_form->get_properties();
     foreach ($props as $prop => $value) {
         $contact_form->{$prop} = wpcf7_get_default_template($prop);
     }
     $contact_form = apply_filters('wpcf7_contact_form_default_pack', $contact_form, $args);
     if (isset($mo_orig)) {
         $l10n['contact-form-7'] = $mo_orig;
     }
     return $contact_form;
 }
Ejemplo n.º 4
0
function wpcf7_install()
{
    if ($opt = get_option('wpcf7')) {
        return;
    }
    wpcf7_load_textdomain();
    wpcf7_register_post_types();
    wpcf7_upgrade();
    if (get_posts(array('post_type' => 'wpcf7_contact_form'))) {
        return;
    }
    $contact_form = WPCF7_ContactForm::get_template(array('title' => sprintf(__('Contact form %d', 'contact-form-7'), 1)));
    $contact_form->save();
    WPCF7::update_option('bulk_validate', array('timestamp' => current_time('timestamp'), 'version' => WPCF7_VERSION, 'count_valid' => 1, 'count_invalid' => 0));
}
Ejemplo n.º 5
-1
 /**
  * Load selected template and translate.
  * 
  * @uses wpcf7_load_textdomain
  * @since 0.0.1
  */
 function load_template()
 {
     // Check the nonce and if not valid, just die.
     if (!isset($_POST['nonce']) || !wp_verify_nonce($_POST['nonce'], 'cf7s')) {
         die;
     }
     // Get translation if locale is set and exists in the Contact Form 7 l10n
     if (isset($_POST['locale']) && !empty($_POST['locale']) && array_key_exists($_POST['locale'], wpcf7_l10n())) {
         wpcf7_load_textdomain($_POST['locale']);
     }
     // Get translation based on post ID
     if (isset($_POST['post']) && !empty($_POST['post'])) {
         $wpcf7 = wpcf7_contact_form((int) $_POST['post']);
         // current CF7 form
         wpcf7_load_textdomain($wpcf7->locale);
     }
     // Load selected template file
     $templates = $this->cf7s_get_template_list();
     $template = $templates[$_POST['template']];
     require_once $template['path'] . trailingslashit($template['dir']) . $template['index'];
     exit;
 }