Beispiel #1
0
function wpcf7_is_valid_locale($locale)
{
    $l10n = wpcf7_l10n();
    return isset($l10n[$locale]);
}
Beispiel #2
0
function wpcf7_admin_lang_select_modal()
{
    $available_locales = wpcf7_l10n();
    $default_locale = get_locale();
    if (!isset($available_locales[$default_locale])) {
        $default_locale = 'en_US';
    }
    ?>
<div id="wpcf7-lang-select-modal" class="hidden">
<h4><?php 
    echo esc_html(sprintf(__('Use the default language (%s)', 'wpcf7'), $available_locales[$default_locale]));
    ?>
</h4>
<p><a href="<?php 
    echo esc_url(add_query_arg(array('post' => 'new'), menu_page_url('wpcf7', false)));
    ?>
" class="button" /><?php 
    echo esc_html(__('Add New', 'wpcf7'));
    ?>
</a></p>

<?php 
    unset($available_locales[$default_locale]);
    ?>
<h4><?php 
    echo esc_html(__('Or', 'wpcf7'));
    ?>
</h4>
<form action="" method="get">
<input type="hidden" name="page" value="wpcf7" />
<input type="hidden" name="post" value="new" />
<select name="locale">
<option value="" selected="selected"><?php 
    echo esc_html(__('(select language)', 'wpcf7'));
    ?>
</option>
<?php 
    foreach ($available_locales as $code => $locale) {
        ?>
<option value="<?php 
        echo esc_attr($code);
        ?>
"><?php 
        echo esc_html($locale);
        ?>
</option>
<?php 
    }
    ?>
</select>
<input type="submit" class="button" value="<?php 
    echo esc_attr(__('Add New', 'wpcf7'));
    ?>
" />
</form>
</div>
<?php 
}
    wp_nonce_field('meta-box-order', 'meta-box-order-nonce', false);
    wp_nonce_field('closedpostboxes', 'closedpostboxesnonce', false);
    ?>
	</div>

</form>

<?php 
}
?>

</div>

<div id="wpcf7-lang-select-modal" class="hidden">
<?php 
$available_locales = wpcf7_l10n();
$default_locale = get_locale();
if (!isset($available_locales[$default_locale])) {
    $default_locale = 'en_US';
}
?>
<h4><?php 
echo esc_html(sprintf(__('Use the default language (%s)', 'wpcf7'), $available_locales[$default_locale]));
?>
</h4>
<p><a href="<?php 
echo wpcf7_admin_url(array('contactform' => 'new'));
?>
" class="button" /><?php 
echo esc_html(__('Add New', 'wpcf7'));
?>
function wpcf7_admin_add_new_page()
{
    if ($post = wpcf7_get_current_contact_form()) {
        $post_id = -1;
        require_once WPCF7_PLUGIN_DIR . '/admin/includes/editor.php';
        require_once WPCF7_PLUGIN_DIR . '/admin/edit-contact-form.php';
        return;
    }
    $available_locales = wpcf7_l10n();
    $default_locale = get_locale();
    if (!isset($available_locales[$default_locale])) {
        $default_locale = 'en_US';
    }
    ?>
<div class="wrap">

<h2><?php 
    echo esc_html(__('Add New Contact Form', 'contact-form-7'));
    ?>
</h2>

<?php 
    do_action('wpcf7_admin_notices');
    ?>

<h3><?php 
    echo esc_html(sprintf(__('Use the default language (%s)', 'contact-form-7'), $available_locales[$default_locale]));
    ?>
</h3>
<p><a href="<?php 
    echo esc_url(add_query_arg(array('locale' => $default_locale), menu_page_url('wpcf7-new', false)));
    ?>
" class="button button-primary" /><?php 
    echo esc_html(__('Add New', 'contact-form-7'));
    ?>
</a></p>

<?php 
    unset($available_locales[$default_locale]);
    ?>
<h3><?php 
    echo esc_html(__('Or', 'contact-form-7'));
    ?>
</h3>
<form action="" method="get">
<input type="hidden" name="page" value="wpcf7-new" />
<select name="locale">
<option value="" selected="selected"><?php 
    echo esc_html(__('(select language)', 'contact-form-7'));
    ?>
</option>
<?php 
    foreach ($available_locales as $code => $locale) {
        ?>
<option value="<?php 
        echo esc_attr($code);
        ?>
"><?php 
        echo esc_html($locale);
        ?>
</option>
<?php 
    }
    ?>
</select>
<input type="submit" class="button" value="<?php 
    echo esc_attr(__('Add New', 'contact-form-7'));
    ?>
" />
</form>
</div>
<?php 
}
 /**
  * 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;
 }