示例#1
0
/**
 * Returns the main instance of Lexicata_Form to prevent the need to use globals.
 *
 * @since  1.0.0
 * @return object Lexicata_Form
 */
function Lexicata_Form()
{
    $instance = Lexicata_Form::instance(__FILE__, '1.0.7');
    if (is_null($instance->settings)) {
        $instance->settings = Lexicata_Form_Settings::instance($instance);
    }
    return $instance;
}
 /**
  * Load settings page content
  * @return void
  */
 public function settings_page()
 {
     $html = '';
     // Specify custom styles
     $html .= '<style>';
     //$html .= '#lf_logo_area {background-color: white; margin-bottom: 20px; }';
     $html .= '#lexicata_form_settings legend { color: #0eace8; font-weight: bold; } ';
     $html .= '#lexicata_form_settings fieldset { border: 1px solid #dedede; padding-left: 10px; margin-bottom: 20px; }';
     $html .= 'fieldset#lf_settings_fields input[type=text] { width: 350px; }';
     $html .= '#lexicata_form_settings span.description { display: block; }';
     #so they show up on new line
     $html .= '#lf_form_preview {width: 300px; background-color: white; padding: 5px; border: 1px solid #dedede; margin: 5px; }';
     $html .= '#lf_form_preview label.description { display: block; }';
     $html .= '#lf_form_preview input[type=text], #lf_form_preview input[type=email], #lf_form_preview textarea {width: 290px; }';
     $html .= '</style>';
     // Build page HTML
     $html .= '<div class="wrap" id="' . $this->parent->_token . '_settings">' . "\n";
     //$html .= '<h2>' . __( 'Lexicata Settings' , 'lexicata-form' ) . '</h2>' . "\n";
     $html .= '<div id="lf_logo_area">';
     $html .= '<img src="' . plugins_url('templates/images/lexicata-logo-169x75.png', __FILE__) . '" />';
     $html .= '</div>';
     $tab = '';
     if (isset($_GET['tab']) && $_GET['tab']) {
         $tab .= $_GET['tab'];
     }
     // Show page tabs
     if (is_array($this->settings) && 1 < count($this->settings)) {
         $html .= '<h2 class="nav-tab-wrapper">' . "\n";
         $c = 0;
         foreach ($this->settings as $section => $data) {
             // Set tab class
             $class = 'nav-tab';
             if (!isset($_GET['tab'])) {
                 if (0 == $c) {
                     $class .= ' nav-tab-active';
                 }
             } else {
                 if (isset($_GET['tab']) && $section == $_GET['tab']) {
                     $class .= ' nav-tab-active';
                 }
             }
             // Set tab link
             $tab_link = add_query_arg(array('tab' => $section));
             if (isset($_GET['settings-updated'])) {
                 $tab_link = remove_query_arg('settings-updated', $tab_link);
             }
             // Output tab
             $html .= '<a href="' . $tab_link . '" class="' . esc_attr($class) . '">' . esc_html($data['title']) . '</a>' . "\n";
             ++$c;
         }
         $html .= '</h2>' . "\n";
     }
     $html .= '<fieldset>';
     $html .= '<legend>Shortcode</legend>';
     $html .= '<br /><input type="text" readonly="readonly" value="[lexicata-contact-form]" />';
     $html .= '<p>Copy and paste the above shortcode into the page or post you wish to use the contact form on. For example, contact us page.</p>';
     $html .= '</fieldset>';
     $html .= '<fieldset id="lf_settings_fields">';
     $html .= '<legend>Configuration</legend>';
     $html .= '<form method="post" action="options.php" enctype="multipart/form-data">' . "\n";
     // Get settings fields
     ob_start();
     settings_fields($this->parent->_token . '_settings');
     do_settings_sections($this->parent->_token . '_settings');
     $html .= ob_get_clean();
     $html .= '<p class="submit">' . "\n";
     $html .= '<input type="hidden" name="tab" value="' . esc_attr($tab) . '" />' . "\n";
     $html .= '<input name="Submit" type="submit" class="button-primary" value="' . esc_attr(__('Save Settings', 'lexicata-form')) . '" />' . "\n";
     $html .= '</p>' . "\n";
     $html .= '</form>' . "\n";
     $html .= '</fieldset>';
     #Begin Admin Preview Block #
     $html .= '<fieldset>';
     $html .= '<legend>Form Preview</legend>';
     $html .= '<p>This is sample of the content of the form to be displayed. The actual look and feel of the form will be determined by your Wordpress Theme.</p>';
     $html .= '<div id="lf_form_preview">';
     $instance = Lexicata_Form::instance(__FILE__, '1.0.0');
     $html .= $instance->setup_contact_form();
     $html .= '</div>';
     $html .= '</fieldset>';
     #End Admin Preview Block #
     $html .= '</div>' . "\n";
     echo $html;
 }
示例#3
0
 /**
  * Main Lexicata_Form Instance
  *
  * Ensures only one instance of Lexicata_Form is loaded or can be loaded.
  *
  * @since 1.0.0
  * @static
  * @see Lexicata_Form()
  * @return Main Lexicata_Form instance
  */
 public static function instance($file = '', $version = '1.0.0')
 {
     if (is_null(self::$_instance)) {
         self::$_instance = new self($file, $version);
     }
     return self::$_instance;
 }