Beispiel #1
0
/**
 * Output cpanel tab content
 *
 * @package Infinity
 * @subpackage dashboard
 */
function infinity_dashboard_cpanel_tabs_content()
{
    $action = infinity_dashboard_cpanel_action();
    $screen = Infinity_Screens_Policy::instance()->registry()->get($action);
    if ($screen instanceof ICE_Screen) {
        ICE_Ajax::responseBegin();
        $screen->render();
        ICE_Ajax::responseEnd(true);
    } else {
        ICE_Ajax::responseStd(false, sprintf(__('There was an error while trying to load the %s tab content.', infinity_text_domain), $action));
    }
}
Beispiel #2
0
 /**
  * Switch theme
  *
  * @todo make sure template is a theme which implements the scheme
  */
 public function ajax_switch_theme()
 {
     // check for post id
     if (isset($_POST['template']) && isset($_POST['stylesheet'])) {
         // we are switching here people
         $template = trim($_POST['template']);
         $stylesheet = trim($_POST['stylesheet']);
         // attempt to activate the theme
         // this function does not return a freaking value, come on!!!
         switch_theme($template, $stylesheet);
         // have to assume it worked
         ICE_Ajax::response(true, __('Theme activated', infinity_text_domain));
     } else {
         ICE_Ajax::response(false, __('Theme activation failed', infinity_text_domain));
     }
 }
Beispiel #3
0
 /**
  * Process the form and generate an AJAX response
  *
  * @see process_form
  */
 public function process_form_ajax()
 {
     // process the form
     $save_count = $this->process_form();
     // any options saved successfuly?
     if ($save_count == 1) {
         ICE_Ajax::responseStd(true, sprintf(__('%d option successfully updated.', infinity_text_domain), $save_count));
     } elseif ($save_count > 1) {
         ICE_Ajax::responseStd(true, sprintf(__('%d options successfully updated.', infinity_text_domain), $save_count));
     } else {
         ICE_Ajax::responseStd(false, __('An error has occurred. No options were updated.', infinity_text_domain));
     }
 }
Beispiel #4
0
 /**
  * Get the url for a media attachment for an AJAX request
  */
 public function ajax_media_url()
 {
     if (isset($_POST['attachment_id']) && is_numeric($_POST['attachment_id'])) {
         // determine size to retrieve
         $size = isset($_POST['attachment_size']) ? $_POST['attachment_size'] : 'full';
         // try to get the attachment info
         $src = wp_get_attachment_image_src($_POST['attachment_id'], $size);
         // check it out
         if (is_array($src)) {
             ICE_Ajax::response(true, $src[0], $src[1], $src[2]);
         } else {
             ICE_Ajax::response(false, __('Failed to lookup attachment URL', infinity_text_domain));
         }
     } else {
         ICE_Ajax::response(0, __('No attachment ID received', infinity_text_domain));
     }
 }
Beispiel #5
0
 /**
  * Trash a single post
  */
 public function ajax_post_trash()
 {
     // check for post id
     if (isset($_POST['post_id']) && is_numeric($_POST['post_id'])) {
         // got one
         $post_id = (int) $_POST['post_id'];
         // attempt to trash the post
         if (wp_trash_post($post_id) !== false) {
             ICE_Ajax::response(true, __('Item moved to trash', infinity_text_domain));
         } else {
             ICE_Ajax::response(false, __('Move item to trash failed', infinity_text_domain));
         }
     } else {
         ICE_Ajax::response(false, __('Missing item id', infinity_text_domain));
     }
 }
Beispiel #6
0
/**
 * Render options according to the option name POST var
 *
 * @package Infinity-api
 * @subpackage options
 */
function infinity_options_render_options_screen()
{
    // section
    $load_section = null;
    if (!empty($_POST['load_section'])) {
        $load_section = $_POST['load_section'];
    } else {
        ICE_Ajax::responseStd(false, 'Missing required "load_section" parameter');
    }
    // option
    $load_option = null;
    if (!empty($_POST['load_option'])) {
        $load_option = $_POST['load_option'];
    }
    // options to render
    $options = array();
    // look up section
    $section = Infinity_Sections_Policy::instance()->registry()->get($load_section);
    // did we get a valid section?
    if ($section instanceof ICE_Section) {
        // load specific option?
        if ($load_option) {
            // look up the single option
            $option = Infinity_Options_Policy::instance()->registry()->get($load_option);
            // did we get a valid option?
            if ($option instanceof ICE_Option) {
                // add it to options to array
                $options[] = $option;
            }
        } else {
            // get all options for the section
            $options = Infinity_Options_Policy::instance()->registry()->get_menu_options($section);
        }
    }
    // content to return
    $content = null;
    // option content
    $option_content = null;
    // loop through all options and render each one
    foreach ($options as $option_to_render) {
        // enable post override
        $option_to_render->enable_post_override();
        // try to render the option
        $section->add_component($option_to_render);
    }
    // render the section
    $content = $section->render(false);
    // respond
    if (strlen($content)) {
        ICE_Ajax::responseStd(true, null, $content);
    } else {
        ICE_Ajax::responseStd(false, __('Failed to render options', infinity_text_domain));
    }
}