function _load_more() { $id = $_REQUEST['id']; $page = (int) $_REQUEST['page']; $gallery = new ASG_Gallery($id); header('Content-type: text/json'); $images = $gallery->get_images($page); ob_start(); $gallery->render_images($images); $images = ob_get_clean(); echo json_encode(array('images' => $images, 'have_more' => $gallery->have_more($page))); exit; }
function _save_post($id, $post) { if ($post->post_type != ASG_POST_TYPE) { return; } if (isset($_REQUEST['asg-hack'])) { $data = $this->parse_query(stripslashes($_REQUEST['asg-hack'])); } $gallery = null; if (isset($data) && isset($data['asg'])) { $gallery = $data['asg']; if (isset($_REQUEST['preset']) && $_REQUEST['preset']) { $presets = asg_get_presets(); $preset_data = $presets[(int) $_REQUEST['preset']]['data']; $gallery = asg_parse_args(asg_parse_args($gallery, asg_get_default_preset()), $preset_data); } //Cleanup delete_post_meta($post->ID, '_asg'); $json = addslashes(json_encode($gallery)); update_post_meta($post->ID, '_asg_json', $json); } remove_action('save_post', array($this, '_save_post')); if (isset($_REQUEST['post_title'])) { wp_update_post(array('ID' => $id, 'post_name' => sanitize_title(stripslashes($_POST['post_title'])))); } add_action('save_post', array($this, '_save_post')); ASG_Gallery::drop_cache($id); if ($post->post_status == 'draft') { wp_update_post(array('ID' => $id, 'post_status' => 'publish')); } }
function asg_refresh_gallery($options = array()) { if (!isset($options['id'])) { return; } $id = $options['id']; $gallery = new ASG_Gallery($id, asg_get_gallery($id)); $gallery->get_images(1, true); $gallery->get_images(2, true); }