예제 #1
0
function id_setup_nags()
{
    $settings = getSettings();
    // Let's check if the notices have been cleared before
    $settings_notice = get_option('id_settings_notice');
    $defaults_notice = get_option('id_defaults_notice');
    $products_notice = get_option('id_products_notice');
    $idf_notice = get_option('id_idf_notice');
    if (empty($settings) && empty($settings_notice)) {
        // add settings nag
        add_action('admin_notices', 'id_settings_notice');
    }
    $defaults = getProductDefaultSettings();
    if ((empty($defaults) || !is_object($defaults)) && empty($defaults_notice)) {
        // add defaults nag
        add_action('admin_notices', 'id_defaults_notice');
    }
    $products = ID_Project::get_all_projects();
    if (empty($products) && empty($products_notice)) {
        // add products nag
        add_action('admin_notices', 'id_products_notice');
    }
    if (!idf_exists() && empty($idf_notice)) {
        add_action('admin_notices', 'id_idf_notice');
    }
}
function idpp_products_handler()
{
    $projects = ID_Project::get_all_projects();
    print_r(json_encode($projects));
    exit;
}
예제 #3
0
function fivehundred_admin_menu()
{
    if (isset($_POST['submit-theme-settings'])) {
        $posts = array();
        foreach ($_POST as $k => $v) {
            $posts[$k] = esc_attr($v);
        }
        do_action('fh_settings_submit', $posts);
        $logo = esc_attr($_POST['logo-input']);
        $about = stripslashes($_POST['about-us']);
        if (isset($_POST['choose-home'])) {
            $home = absint($_POST['choose-home']);
        } else {
            $home = null;
        }
        $home_projects = absint($_POST['home-projects']);
        $blog_page = absint($_POST['blog_page']);
        $custom_css = stripslashes($_POST['custom_css']);
        $ga = stripslashes($_POST['ga']);
        if (isset($_POST['twitter-button'])) {
            $twitter = absint($_POST['twitter-button']);
        } else {
            $twitter = 0;
        }
        if (isset($_POST['fb-button'])) {
            $fb = absint($_POST['fb-button']);
        } else {
            $fb = 0;
        }
        if (isset($_POST['g-button'])) {
            $google = absint($_POST['g-button']);
        } else {
            $google = 0;
        }
        if (isset($_POST['li-button'])) {
            $li = absint($_POST['li-button']);
        } else {
            $li = 0;
        }
        $twitter_via = esc_attr(str_replace('@', '', $_POST['twitter-via']));
        $fbname = esc_attr($_POST['fb-via']);
        $gname = esc_attr($_POST['g-via']);
        $liname = esc_attr($_POST['li-via']);
        $settings = array('logo' => $logo, 'about' => esc_html(html_entity_decode($about)), 'home' => $home, 'home_projects' => $home_projects, 'blog_page' => $blog_page, 'custom_css' => $custom_css, 'ga' => $ga, 'twitter' => $twitter, 'twitter_via' => $twitter_via, 'fb' => $fb, 'fb_via' => $fbname, 'google' => $google, 'g_via' => $gname, 'li' => $li, 'li_via' => $liname);
        update_option('fivehundred_theme_settings', apply_filters('fh_theme_settings', $settings, $posts));
        if (isset($_POST['choose-featured']) && $_POST['choose-featured'] > 0) {
            $project_id = absint($_POST['choose-featured']);
            $project = new ID_Project($project_id);
            $post_id = $project->get_project_postid();
            if (!empty($post_id)) {
                $options = array('post_id' => $post_id, 'project_id' => $project_id);
                update_option('fivehundred_featured', apply_filters('fh_featured', $options));
            }
        } else {
            delete_option('fivehundred_featured');
        }
        echo '<div class="updated fade below-h2" id="message"><p>' . __('Settings Saved', 'fivehundred') . '</p></div>';
    } else {
        $settings = get_option('fivehundred_theme_settings');
        $logo = $settings['logo'];
        $about = html_entity_decode($settings['about']);
        $home_projects = $settings['home_projects'];
        $blog_page = $settings['blog_page'];
        $custom_css = stripslashes($settings['custom_css']);
        $ga = stripslashes($settings['ga']);
        $options = get_option('fivehundred_featured');
        if ($options) {
            $post_id = $options['post_id'];
            $project_id = $options['project_id'];
        }
    }
    // set up the project home page dropdown
    if (class_exists('ID_Project')) {
        $projects = ID_Project::get_all_projects();
        $levels = '<select id="choose-home" name="choose-home">' . apply_filters("home_grid_option", '<option value="">' . __("Grid Layout", "fivehundred") . '</option>');
        foreach ($projects as $project) {
            $a_project = new ID_Project($project->id);
            $post_id = $a_project->get_project_postid();
            $selected = null;
            if (isset($_POST['choose-home']) && $_POST['choose-home'] == $project->id) {
                $selected = 'selected="selected"';
            } else {
                if (isset($settings['home']) && $settings['home'] == $project->id) {
                    $selected = 'selected="selected"';
                }
            }
            $post = get_post($post_id);
            if (!empty($post)) {
                $levels .= '<option value="' . $project->id . '" ' . (isset($selected) ? $selected : '') . '>' . __('Single Project', 'fivehundred') . ': ' . stripslashes(get_the_title($post_id)) . '</option>';
            }
        }
        $levels .= '</select>';
    } else {
        $levels = null;
    }
    include 'templates/admin/_themeSettings.php';
}
function api_get_all_projects()
{
    $projects = ID_Project::get_all_projects();
    print_r(json_encode($projects));
    exit;
}