/** * Sets up rtPanel * * @uses add_theme_support() To add support for post thumbnails and automatic feed links. * @uses register_nav_menus() To add support for navigation menus. * * @since rtPanel 2.0 */ function rtpanel_setup() { rtp_theme_setup_values(); add_theme_support('post-thumbnails'); // This theme uses post thumbnails add_theme_support('title-tag'); // This feature enables plugins and themes to manage the document title. add_editor_style('style.css'); // This theme styles the visual editor with the themes style.css itself. load_theme_textdomain('rtPanel', get_template_directory() . '/languages'); // Load the text domain add_theme_support('custom-background'); // Add support for custom background // Add support for custom headers. $rtp_custom_header_support = array('width' => apply_filters('rtp_header_image_width', 1200), 'height' => apply_filters('rtp_header_image_height', 200), 'header-text' => false, 'wp-head-callback' => '', 'admin-head-callback' => ''); add_theme_support('custom-header', $rtp_custom_header_support); /* * Switches default core markup for search form, comment form, * and comments to output valid HTML5. */ add_theme_support('html5', array('search-form', 'comment-form', 'comment-list')); /** * Adds RSS feed links to head for posts and comments. */ add_theme_support('automatic-feed-links'); // Make use of wp_nav_menu() for navigation purpose register_nav_menus(array('primary' => __('Primary Navigation', 'rtPanel'))); }
/** * Data validation for rtPanel Post & Comments Options * * @uses $rtp_post_comments array * @param array $input all post & comments options inputs. * @return Array * * @since rtPanel 2.0 */ function rtp_post_comments_validate($input) { global $rtp_post_comments; $default = rtp_theme_setup_values(); if (isset($_POST['rtp_submit'])) { $input['notices'] = $rtp_post_comments['notices']; if ($input['summary_show']) { $updated = 0; if (trim($input['read_text']) != $rtp_post_comments['read_text']) { $input['read_text'] = trim($input['read_text']); $updated++; } if (!preg_match('/^[0-9]{1,3}$/i', $input['word_limit'])) { $input['word_limit'] = $rtp_post_comments['word_limit']; add_settings_error('word_limit', 'invalid_word_limit', __('The Word Limit provided is invalid. Please provide a proper value.', 'rtPanel')); } elseif (trim($input['word_limit']) != $rtp_post_comments['word_limit']) { $updated++; } if ($updated) { add_settings_error('post_summary_settings', 'post_summary_settings', __('The Post Summary Settings have been updated.', 'rtPanel'), 'updated'); } if ($input['thumbnail_show']) { $updated = 0; if (!preg_match('/^[0-9]{1,3}$/i', $input['thumbnail_width'])) { $input['thumbnail_width'] = get_option('thumbnail_size_w'); add_settings_error('thumbnail_width', 'invalid_thumbnail_width', __('The Thumbnail Width provided is invalid. Please provide a proper value.', 'rtPanel')); } elseif (get_option('thumbnail_size_w') != $input['thumbnail_width']) { $input['notices'] = '1'; update_option('thumbnail_size_w', $input['thumbnail_width']); $updated++; } if (!preg_match('/^[0-9]{1,3}$/i', $input['thumbnail_height'])) { $input['thumbnail_height'] = get_option('thumbnail_size_h'); add_settings_error('thumbnail_height', 'invalid_thumbnail_height', __('The Thumbnail Height provided is invalid. Please provide a proper value.', 'rtPanel')); } elseif (get_option('thumbnail_size_h') != $input['thumbnail_height']) { $input['notices'] = '1'; update_option('thumbnail_size_h', $input['thumbnail_height']); $updated++; } if ($input['thumbnail_crop'] != get_option('thumbnail_crop')) { $input['notices'] = '1'; update_option('thumbnail_crop', $input['thumbnail_crop']); $updated++; } if ($updated) { add_settings_error('post_thumbnail_settings', 'post_thumbnail_settings', __('The Post Thumbnail Settings have been updated', 'rtPanel'), 'updated'); } } else { $input['thumbnail_position'] = $rtp_post_comments['thumbnail_position']; $input['thumbnail_frame'] = $rtp_post_comments['thumbnail_frame']; } } else { $input['thumbnail_show'] = $rtp_post_comments['thumbnail_show']; $input['word_limit'] = $rtp_post_comments['word_limit']; $input['read_text'] = $rtp_post_comments['read_text']; $input['thumbnail_position'] = $rtp_post_comments['thumbnail_position']; $input['thumbnail_frame'] = $rtp_post_comments['thumbnail_frame']; } if (!in_array($input['post_date_format_u'], array($rtp_post_comments['post_date_format_u'], 'F j, Y', 'Y/m/d', 'm/d/Y', 'd/m/Y'))) { $input['post_date_format_u'] = str_replace('<', '', $input['post_date_format_u']); $input['post_date_format_l'] = str_replace('<', '', $input['post_date_format_l']); $input['post_date_custom_format_u'] = str_replace('<', '', $input['post_date_custom_format_u']); $input['post_date_custom_format_l'] = str_replace('<', '', $input['post_date_custom_format_l']); } if (!$input['post_date_u']) { $input['post_date_format_u'] = $rtp_post_comments['post_date_format_u']; $input['post_date_custom_format_u'] = $rtp_post_comments['post_date_custom_format_u']; } if (!$input['post_date_l']) { $input['post_date_format_l'] = $rtp_post_comments['post_date_format_l']; $input['post_date_custom_format_l'] = $rtp_post_comments['post_date_custom_format_l']; } if (!$input['post_author_u']) { $input['author_count_u'] = $rtp_post_comments['author_count_u']; $input['author_link_u'] = $rtp_post_comments['author_link_u']; } if (!$input['post_author_l']) { $input['author_count_l'] = $rtp_post_comments['author_count_l']; $input['author_link_l'] = $rtp_post_comments['author_link_l']; } if ($input['pagination_show']) { $updated = 0; if (trim($input['prev_text']) != $rtp_post_comments['prev_text']) { $input['prev_text'] = trim($input['prev_text']); $updated++; } if (trim($input['next_text']) != $rtp_post_comments['next_text']) { $input['next_text'] = trim($input['next_text']); $updated++; } if (!preg_match('/^[0-9]{1,3}$/i', $input['end_size'])) { $input['end_size'] = $rtp_post_comments['end_size']; add_settings_error('end_size', 'invalid_end_size', __('The End Size provided is invalid. Please provide a proper value.', 'rtPanel')); } if (!preg_match('/^[0-9]{1,3}$/i', $input['mid_size'])) { $input['mid_size'] = $rtp_post_comments['mid_size']; add_settings_error('mid_size', 'invalid_mid_size', __('The Mid Size provided is invalid. Please provide a proper value.', 'rtPanel')); } if ($updated) { add_settings_error('pagination_settings', 'pagination_settings', __('The Pagination Settings have been updated.', 'rtPanel'), 'updated'); } } else { $input['prev_text'] = $rtp_post_comments['prev_text']; $input['next_text'] = $rtp_post_comments['next_text']; $input['end_size'] = $rtp_post_comments['end_size']; $input['mid_size'] = $rtp_post_comments['mid_size']; } } elseif (isset($_POST['rtp_summary_reset'])) { $options = maybe_unserialize($rtp_post_comments); unset($input); foreach ($options as $option => $value) { $input[$option] = $value; } $input['notices'] = $rtp_post_comments['notices']; $input['summary_show'] = $default[1]['summary_show']; $input['word_limit'] = $default[1]['word_limit']; $input['read_text'] = $default[1]['read_text']; add_settings_error('summary', 'reset_summary', __('The Post Summary Settings have been restored to default.', 'rtPanel'), 'updated'); } elseif (isset($_POST['rtp_thumbnail_reset'])) { $options = maybe_unserialize($rtp_post_comments); unset($input); foreach ($options as $option => $value) { $input[$option] = $value; } $input['notices'] = $rtp_post_comments['notices']; $input['thumbnail_show'] = $default[1]['thumbnail_show']; $input['thumbnail_position'] = $default[1]['thumbnail_position']; $input['thumbnail_frame'] = $default[1]['thumbnail_frame']; add_settings_error('thumbnail', 'reset_thumbnail', __('The Post Thumbnail Settings have been restored to default.', 'rtPanel'), 'updated'); } elseif (isset($_POST['rtp_meta_reset'])) { $options = maybe_unserialize($rtp_post_comments); unset($input); foreach ($options as $option => $value) { $input[$option] = $value; } $input['notices'] = $rtp_post_comments['notices']; $input['post_date_u'] = $default[1]['post_date_u']; $input['post_date_format_u'] = $default[1]['post_date_format_u']; $input['post_date_custom_format_u'] = $default[1]['post_date_custom_format_u']; $input['post_author_u'] = $default[1]['post_author_u']; $input['author_count_u'] = $default[1]['author_count_u']; $input['author_link_u'] = $default[1]['author_link_u']; $input['post_category_u'] = $default[1]['post_category_u']; $input['post_tags_u'] = $default[1]['post_tags_u']; $input['post_date_l'] = $default[1]['post_date_l']; $input['post_date_format_l'] = $default[1]['post_date_format_l']; $input['post_date_custom_format_l'] = $default[1]['post_date_custom_format_l']; $input['post_author_l'] = $default[1]['post_author_l']; $input['author_count_l'] = $default[1]['author_count_l']; $input['author_link_l'] = $default[1]['author_link_l']; $input['post_category_l'] = $default[1]['post_category_l']; $input['post_tags_l'] = $default[1]['post_tags_l']; $args = array('_builtin' => false); $taxonomies = get_taxonomies($args, 'names'); if (!empty($taxonomies)) { foreach ($taxonomies as $taxonomy) { $input['post_' . $taxonomy . '_u'] = '0'; $input['post_' . $taxonomy . '_l'] = '0'; } } add_settings_error('post_meta', 'reset_post_meta', __('The Post Meta Settings have been restored to default.', 'rtPanel'), 'updated'); } elseif (isset($_POST['rtp_pagination_reset'])) { $options = maybe_unserialize($rtp_post_comments); unset($input); foreach ($options as $option => $value) { $input[$option] = $value; } $input['notices'] = $rtp_post_comments['notices']; $input['pagination_show'] = $default[1]['pagination_show']; $input['prev_text'] = $default[1]['prev_text']; $input['next_text'] = $default[1]['next_text']; $input['end_size'] = $default[1]['end_size']; $input['mid_size'] = $default[1]['mid_size']; add_settings_error('pagination', 'reset_pagination', __('The Pagination Settings have been restored to default.', 'rtPanel'), 'updated'); } elseif (isset($_POST['rtp_comment_reset'])) { $options = maybe_unserialize($rtp_post_comments); unset($input); foreach ($options as $option => $value) { $input[$option] = $value; } $input['notices'] = $rtp_post_comments['notices']; $input['compact_form'] = $default[1]['compact_form']; $input['hide_labels'] = $default[1]['hide_labels']; $input['comment_textarea'] = $default[1]['comment_textarea']; $input['comment_separate'] = $default[1]['comment_separate']; $input['gravatar_show'] = $default[1]['gravatar_show']; add_settings_error('comment', 'reset_comment', __('The Comment Settings have been restored to default.', 'rtPanel'), 'updated'); } elseif (isset($_POST['rtp_reset'])) { $input = $default[1]; $input['notices'] = $rtp_post_comments['notices']; $args = array('_builtin' => false); $taxonomies = get_taxonomies($args, 'names'); if (!empty($taxonomies)) { foreach ($taxonomies as $taxonomy) { $input['post_' . $taxonomy . '_u'] = '0'; $input['post_' . $taxonomy . '_l'] = '0'; } } add_settings_error('rtp_post_comments', 'reset_post_comments_options', __('All the rtPanel Post & Comments Settings have been restored to default.', 'rtPanel'), 'updated'); } return $input; // return validated input }