Esempio n. 1
0
function hocwp_setup_body_class($classes)
{
    $classes[] = 'hocwp';
    if (is_multi_author()) {
        $classes[] = 'group-blog';
    }
    if (is_user_logged_in()) {
        $role = hocwp_get_user_role();
        $role = hocwp_sanitize($role, 'html_class');
        $classes[] = 'role-' . $role;
    }
    return $classes;
}
    public function default_setting_page_callback()
    {
        $parent_slug = $this->get_parent_slug();
        if (empty($parent_slug)) {
            return;
        }
        $disable_sidebar = (bool) $this->disable_sidebar;
        $title = $this->get_heading_text();
        if ($this->is_option_page() && !hocwp_string_contain(strtolower($title), 'settings') && !hocwp_string_contain(strtolower($title), 'options')) {
            hocwp_add_string_with_space_before($title, 'Settings');
        }
        $wrap_class = $this->get_option_name_no_prefix();
        $wrap_class = hocwp_sanitize($wrap_class, 'html_class');
        hocwp_add_string_with_space_before($wrap_class, 'wrap hocwp option-page');
        if (!$disable_sidebar) {
            hocwp_add_string_with_space_before($wrap_class, 'has-sidebar');
        }
        ?>
		<div class="<?php 
        echo $wrap_class;
        ?>
">
			<h1 class="page-title"><?php 
        echo esc_html($title) . $this->get_page_title_action();
        ?>
</h1>
			<?php 
        $header_callback = $this->get_page_header_callback();
        if (hocwp_callback_exists($header_callback)) {
            call_user_func($header_callback);
        }
        $page_content_class = 'page-content';
        if ($disable_sidebar) {
            hocwp_add_string_with_space_before($page_content_class, 'no-sidebar');
        }
        ?>
			<div class="<?php 
        echo $page_content_class;
        ?>
">
				<?php 
        if ((bool) $this->disable_sidebar) {
            if ($this->is_option_page()) {
                if ($this->is_this_page() && (isset($_REQUEST['submit']) || isset($_REQUEST['settings-updated']))) {
                    do_action('hocwp_option_saved');
                    if ('options-general.php' != $this->get_parent_slug() && !$this->get_exists()) {
                        hocwp_admin_notice_setting_saved();
                    }
                    do_action($this->get_menu_slug() . '_option_saved', $this);
                }
                $this->form();
            }
            do_action('hocwp_option_page_content');
            do_action('hocwp_option_page_' . $this->get_option_name_no_prefix() . '_content');
        } else {
            ?>
					<div class="sidebar">
						<?php 
            $sidebar_callback = $this->get_page_sidebar_callback();
            if (hocwp_callback_exists($sidebar_callback)) {
                call_user_func($sidebar_callback);
            }
            ?>
					</div>
					<div class="main main-content">
						<?php 
            if ($this->is_option_page()) {
                if ($this->is_this_page() && (isset($_REQUEST['submit']) || isset($_REQUEST['settings-updated']))) {
                    do_action('hocwp_option_saved');
                    if ('options-general.php' != $this->get_parent_slug() && !$this->get_exists()) {
                        hocwp_admin_notice_setting_saved();
                    }
                    do_action($this->get_menu_slug() . '_option_saved', $this);
                }
                $this->form();
            }
            do_action('hocwp_option_page_content');
            do_action('hocwp_option_page_' . $this->get_option_name_no_prefix() . '_content');
            ?>
					</div>
					<?php 
        }
        ?>
			</div>
			<?php 
        $footer_callback = $this->get_page_footer_callback();
        if (hocwp_callback_exists($footer_callback)) {
            call_user_func($footer_callback);
        }
        ?>
		</div>
		<?php 
    }
Esempio n. 3
0
function hocwp_sanitize_form_post($key, $type = 'default')
{
    switch ($type) {
        case 'checkbox':
            return hocwp_get_method_value($key);
        case 'datetime':
            return isset($_POST[$key]) ? strtotime(hocwp_string_to_datetime($_POST[$key])) : '';
        case 'timestamp':
            $value = isset($_POST[$key]) ? $_POST[$key] : '';
            $value = strtotime($value);
            return $value;
        default:
            return isset($_POST[$key]) ? hocwp_sanitize($_POST[$key], $type) : '';
    }
}