public function box()
    {
        global $post;
        //Create the nonce
        echo '<input type="hidden" name="' . $this->id . '_nonce" id="' . $this->id . '_nonce" value="' . wp_create_nonce(md5($this->id)) . '" />';
        if (method_exists($this, 'modify_arguments')) {
            $this->modify_arguments($post);
        }
        if (isset($this->info)) {
            echo '<div class="alert alert-yellow"><p>' . $this->info . '</p></div>';
        }
        echo '<table cellspacing="2" cellpadding="5" style="width: 100%;" class="form-table headway-admin-meta-box">';
        foreach ($this->inputs as $name => $input) {
            //Change hyphens to underscores with the input types since methods/functions can't have hyphens
            $input['type'] = str_replace('-', '_', $input['type']);
            //The input type doesn't exist--go ahead and skip it
            if (!method_exists($this, 'input_' . $input['type'])) {
                continue;
            }
            if (!isset($input['group'])) {
                $input['group'] = 'general';
            }
            if (!isset($input['default'])) {
                $input['default'] = null;
            }
            $input['attr-id'] = $this->id . '-' . $input['id'];
            $input['attr-name'] = $this->id . '[' . $input['group'] . '][' . $input['id'] . ']';
            $input['value'] = HeadwayLayoutOption::get($post->ID, $input['id'], $input['group'], $input['default']);
            if (headway_get('name', $input)) {
                echo '
						<tr class="label">
							<th valign="top" scope="row">
								<label for="' . $input['attr-id'] . '">' . $input['name'] . '</label>
							</th>
						</tr>
					';
            }
            call_user_func(array($this, 'input_' . $input['type']), $input);
            if (isset($input['description'])) {
                echo '<tr class="description"><td><p>' . $input['description'] . '</p></td></tr>';
            }
        }
        echo '</table>';
    }
Esempio n. 2
0
 public static function is_seo_checkbox_enabled($option, $layout = false)
 {
     $seo_templates = self::get_seo_templates(self::current_seo_layout());
     if (HeadwayLayoutOption::get($layout, $option, 'seo', null) === null && !headway_get($option, $seo_templates)) {
         return false;
     }
     if (HeadwayLayoutOption::get($layout, $option, 'seo', null) === false) {
         return false;
     }
     return true;
 }
Esempio n. 3
0
 /**
  * If a post, page, or any other singular item has the 301 Redirect set, then do the redirect.
  **/
 public static function maybe_redirect_301()
 {
     global $post;
     //Don't try redirecting if the headers are already sent.  Otherwise, it'll result in an error and no redirect.
     if (headers_sent()) {
         return false;
     }
     //Make sure that it's a single post and that $post is a valid object.
     if (!is_object($post) || !is_singular()) {
         return false;
     }
     //Do not try redirecting if it's the visual editor or admin
     if (is_admin() || self::is_visual_editor() || self::is_visual_editor_iframe()) {
         return false;
     }
     //If the redirect URL isn't set, then don't try anything.
     if (!($redirect_url = HeadwayLayoutOption::get($post->ID, 'redirect-301', 'seo', false))) {
         return false;
     }
     //If there is no HTTP or HTTPS in the URL, add it.
     if (strpos($redirect_url, 'http://') !== 0 && strpos($redirect_url, 'https://') !== 0) {
         $redirect_url = 'http://' . $redirect_url;
     }
     wp_redirect($redirect_url, 301);
     die;
 }
Esempio n. 4
0
 /**
  * Assembles the classes for the posts.
  *
  * @global object $post
  * @global int $blog_post_alt
  * 
  * @param bool $print Determines whether or not to echo the post classes.
  * 
  * @return bool|string If $print is true, then echo the classes, otherwise just return them as a string. 
  **/
 function entry_class()
 {
     global $post, $blog_post_alt, $authordata;
     $c = get_post_class();
     if (!isset($blog_post_alt)) {
         $blog_post_alt = 1;
     }
     if (is_object($authordata)) {
         $c[] = 'author-' . sanitize_title_with_dashes(strtolower($authordata->user_login));
     }
     if (++$blog_post_alt % 2) {
         $c[] = 'alt';
     }
     //Add the custom classes from the meta box
     if ($custom_css_class = HeadwayLayoutOption::get(get_the_id(), 'css-class', null)) {
         $custom_css_classes = str_replace('  ', ' ', str_replace(',', ' ', htmlspecialchars(strip_tags($custom_css_class))));
         $c = array_merge($c, array_filter(explode(' ', $custom_css_classes)));
     }
     $c = join(' ', $c);
     return $c;
 }
Esempio n. 5
0
 /**
  * Gets the status of the layout.  This will tell if it's customized, using a template, or none of the previous mentioned.
  * 
  * @return string
  **/
 public static function get_status($layout, $include_post_status = false)
 {
     $layout_parts = explode('-', $layout);
     $layout_end_part = end($layout_parts);
     $customized = HeadwayLayoutOption::get($layout, 'customized') === true ? true : false;
     $template = false;
     if ($possible_template = HeadwayLayoutOption::get($layout, 'template')) {
         if (self::template_exists($possible_template)) {
             $template = $possible_template;
         }
     }
     $status = array('customized' => $customized, 'template' => $template);
     /* If set to include post status and this is a single layout, fetch it */
     if ($include_post_status && $layout_parts[0] == 'single' && is_numeric($layout_end_part)) {
         /* Change status IDs to friendly statuses */
         $possible_statuses = array('publish', 'pending', 'draft', 'future', 'private');
         $friendly_status_names = array('Published', 'Pending Review', 'Draft', 'Scheduled', 'Private');
         $status['post_status'] = str_replace($possible_statuses, $friendly_status_names, get_post_status($layout_end_part));
     }
     return $status;
 }
Esempio n. 6
0
 /**
  * Assembles the classes for the body element.
  **/
 public static function body_class($c)
 {
     global $wp_query, $authordata;
     $c[] = 'custom';
     /* User Agents */
     if (!HeadwayCompiler::is_plugin_caching()) {
         $user_agent = $_SERVER['HTTP_USER_AGENT'];
         /* IE */
         if ($ie_version = headway_is_ie()) {
             $c[] = 'ie';
             $c[] = 'ie' . $ie_version;
         }
         /* Modern Browsers */
         if (stripos($user_agent, 'Safari') !== false) {
             $c[] = 'safari';
         } elseif (stripos($user_agent, 'Firefox') !== false) {
             $c[] = 'firefox';
         } elseif (stripos($user_agent, 'Chrome') !== false) {
             $c[] = 'chrome';
         } elseif (stripos($user_agent, 'Opera') !== false) {
             $c[] = 'opera';
         }
         /* Rendering Engines */
         if (stripos($user_agent, 'WebKit') !== false) {
             $c[] = 'webkit';
         } elseif (stripos($user_agent, 'Gecko') !== false) {
             $c[] = 'gecko';
         }
         /* Mobile */
         if (stripos($user_agent, 'iPhone') !== false) {
             $c[] = 'iphone';
         } elseif (stripos($user_agent, 'iPod') !== false) {
             $c[] = 'ipod';
         } elseif (stripos($user_agent, 'iPad') !== false) {
             $c[] = 'ipad';
         } elseif (stripos($user_agent, 'Android') !== false) {
             $c[] = 'android';
         }
     }
     /* End User Agents */
     /* Responsive Grid */
     if (HeadwayResponsiveGrid::is_enabled()) {
         $c[] = 'responsive-grid-enabled';
     }
     if (HeadwayResponsiveGrid::is_active()) {
         $c[] = 'responsive-grid-active';
     }
     /* Pages */
     if (is_page() && isset($wp_query->post) && isset($wp_query->post->ID)) {
         $c[] = 'pageid-' . $wp_query->post->ID;
         $c[] = 'page-slug-' . $wp_query->post->post_name;
     }
     /* Posts & Pages */
     if (is_singular() && isset($wp_query->post) && isset($wp_query->post->ID)) {
         //Add the custom classes from the meta box
         if ($custom_css_class = HeadwayLayoutOption::get($wp_query->post->ID, 'css-class', null)) {
             $custom_css_classes = str_replace('  ', ' ', str_replace(',', ' ', htmlspecialchars(strip_tags($custom_css_class))));
             $c = array_merge($c, array_filter(explode(' ', $custom_css_classes)));
         }
     }
     /* Layout IDs, etc */
     $c[] = 'layout-' . HeadwayLayout::get_current();
     $c[] = 'layout-using-' . HeadwayLayout::get_current_in_use();
     if (HeadwayRoute::is_visual_editor_iframe()) {
         $c[] = 've-iframe';
     }
     if (headway_get('ve-iframe-mode') && HeadwayRoute::is_visual_editor_iframe()) {
         $c[] = 'visual-editor-mode-' . headway_get('ve-iframe-mode');
     }
     if (!current_theme_supports('headway-design-editor')) {
         $c[] = 'design-editor-disabled';
     }
     $c = array_unique(array_filter($c));
     return $c;
 }
 public static function secure_method_remove_template_from_layout()
 {
     $layout = headway_post('layout');
     //Remove the template flag
     if (!HeadwayLayoutOption::set($layout, 'template', false)) {
         echo 'failure';
         return;
     }
     if (HeadwayLayoutOption::get($layout, 'customized', false) === true) {
         echo 'customized';
         return;
     }
     do_action('headway_visual_editor_unassign_template');
     echo 'success';
 }