예제 #1
0
 /**
  * Flushes NextGen Gallery caches
  */
 function flush_cache($args, $assoc_args)
 {
     C_Photocrati_Transient_Manager::flush();
     WP_CLI::success('Flushed all caches');
 }
예제 #2
0
 /**
  * Flush all expires transients created by the plugin
  */
 function delete_expired_transients()
 {
     C_Photocrati_Transient_Manager::flush();
 }
 function reset_action()
 {
     global $wpdb;
     // Flush the cache
     C_Photocrati_Transient_Manager::flush();
     // Uninstall the plugin
     $settings = C_NextGen_Settings::get_instance();
     if (defined('NGG_PRO_PLUGIN_VERSION') || defined('NEXTGEN_GALLERY_PRO_VERSION')) {
         C_Photocrati_Installer::uninstall('photocrati-nextgen-pro');
     }
     C_Photocrati_Installer::uninstall('photocrati-nextgen');
     // removes all ngg_options entry in wp_options
     $settings->reset();
     $settings->destroy();
     // clear NextGEN's capabilities from the roles system
     $capabilities = array("NextGEN Gallery overview", "NextGEN Use TinyMCE", "NextGEN Upload images", "NextGEN Manage gallery", "NextGEN Manage others gallery", "NextGEN Manage tags", "NextGEN Edit album", "NextGEN Change style", "NextGEN Change options", "NextGEN Attach Interface");
     $roles = array("subscriber", "contributor", "author", "editor", "administrator");
     foreach ($roles as $role) {
         $role = get_role($role);
         foreach ($capabilities as $capability) {
             if (!is_null($role)) {
                 $role->remove_cap($capability);
             }
         }
     }
     // Some installations of NextGen that upgraded from 1.9x to 2.0x have duplicates installed,
     // so for now (as of 2.0.21) we explicitly remove all display types and lightboxes from the
     // db as a way of fixing this.
     $wpdb->query($wpdb->prepare("DELETE FROM {$wpdb->posts} WHERE post_type = %s", 'display_type'));
     $wpdb->query($wpdb->prepare("DELETE FROM {$wpdb->posts} WHERE post_type = %s", 'lightbox_library'));
     // the installation will run on the next page load; so make our own request before reloading the browser
     wp_remote_get(admin_url('plugins.php'), array('timeout' => 180, 'blocking' => true, 'sslverify' => false));
     header('Location: ' . get_admin_url());
     throw new E_Clean_Exit();
 }
 public function _save_entity($entity)
 {
     $entity->updated_at = time();
     // If successfully saved, then import metadata and
     $retval = $this->call_parent('_save_entity', $entity);
     if ($retval) {
         include_once NGGALLERY_ABSPATH . '/admin/functions.php';
         $image_id = $this->get_id($entity);
         if (!isset($entity->meta_data['saved'])) {
             nggAdmin::import_MetaData($image_id);
         }
         C_Photocrati_Transient_Manager::flush('displayed_gallery_rendering');
     }
     return $retval;
 }
 /**
  * Uninstalls this module
  */
 function uninstall($hard = FALSE)
 {
     C_Photocrati_Transient_Manager::flush();
     $this->uninstall_display_types();
     // TODO temporary Don't remove galleries on uninstall
     //if ($hard) $this->uninstall_displayed_galleries();
 }
예제 #6
0
/**
 * @author Alex Rabe
 *
 */
function nggallery_sortorder($galleryID = 0)
{
    global $wpdb, $ngg, $nggdb;
    if ($galleryID == 0) {
        return;
    }
    $galleryID = (int) $galleryID;
    if (isset($_POST['updateSortorder'])) {
        check_admin_referer('ngg_updatesortorder');
        // get variable new sortorder
        parse_str($_POST['sortorder']);
        if (is_array($sortArray)) {
            $neworder = array();
            foreach ($sortArray as $pid) {
                $neworder[] = (int) $pid;
            }
            $sortindex = 1;
            foreach ($neworder as $pic_id) {
                $wpdb->query("UPDATE {$wpdb->nggpictures} SET sortorder = '{$sortindex}' WHERE pid = {$pic_id}");
                $sortindex++;
            }
            C_Photocrati_Transient_Manager::flush('displayed_gallery_rendering');
            do_action('ngg_gallery_sort', $galleryID);
            nggGallery::show_message(__('Sort order changed', 'nggallery'));
        }
    }
    // look for presort args
    $presort = isset($_GET['presort']) ? $_GET['presort'] : false;
    $dir = isset($_GET['dir']) && $_GET['dir'] == 'DESC' ? 'DESC' : 'ASC';
    $sortitems = array('pid', 'filename', 'alttext', 'imagedate');
    // ensure that nobody added some evil sorting :-)
    if (in_array($presort, $sortitems)) {
        $picturelist = $nggdb->get_gallery($galleryID, $presort, $dir, false);
    } else {
        $picturelist = $nggdb->get_gallery($galleryID, 'sortorder', $dir, false);
    }
    //this is the url without any presort variable
    $clean_url = 'admin.php?page=nggallery-manage-gallery&mode=sort&gid=' . $galleryID;
    //if we go back , then the mode should be edit
    $back_url = 'admin.php?page=nggallery-manage-gallery&mode=edit&gid=' . $galleryID;
    // In the case somebody presort, then we take this url
    if (isset($_GET['dir']) || isset($_GET['presort'])) {
        $base_url = $_SERVER['REQUEST_URI'];
    } else {
        $base_url = $clean_url;
    }
    ?>
	<script type="text/javascript">
		jQuery(document).ready(function($) {
			if ($(this).data('ready')) return;

			// Enable sorting
			$(".jqui-sortable").sortable({items: 'div.imageBox'});

			$('#sortGallery').submit(function(e){
				var serial = "";
				var $images = $('div.imageBox');
				for (var i=0; i<$images.length; i++) {
					var image_id = $images[i].id.split('-').pop();
					if (serial.length > 0) serial = serial + '&';
					serial = serial + "sortArray[]=" + image_id;
				}
				$('input[name=sortorder]').val(serial);
			});

			// Listen for events in other frames
			if (window.Frame_Event_Publisher) {
				Frame_Event_Publisher.listen_for('attach_to_post:manage_galleries attach_to_post:manage_images', function(){
					window.location.href = window.location.href;
				});
			}

			$(this).data('ready', true);
		});


	</script>
	<div class="wrap">
		<form id="sortGallery" method="POST" action="<?php 
    echo $clean_url;
    ?>
" accept-charset="utf-8">
			<h2><?php 
    _e('Sort Gallery', 'nggallery');
    ?>
</h2>
			<div class="tablenav">
				<div class="alignleft actions">
					<?php 
    wp_nonce_field('ngg_updatesortorder');
    ?>
					<input class="button-primary action" type="submit" name="updateSortorder" value="<?php 
    _e('Update Sort Order', 'nggallery');
    ?>
" />
				</div>
				<div class="alignright actions">
					<a href="<?php 
    echo nextgen_esc_url($back_url);
    ?>
" class="button"><?php 
    _e('Back to gallery', 'nggallery');
    ?>
</a>
				</div>
			</div>
			<input name="sortorder" type="hidden" />
			<ul class="subsubsub">
				<li><?php 
    _e('Presort', 'nggallery');
    ?>
 :</li>
				<li><a href="<?php 
    echo esc_attr(remove_query_arg('presort', $base_url));
    ?>
" <?php 
    if ($presort == '') {
        echo 'class="current"';
    }
    ?>
><?php 
    _e('Unsorted', 'nggallery');
    ?>
</a> |</li>
				<li><a href="<?php 
    echo esc_attr(add_query_arg('presort', 'pid', $base_url));
    ?>
" <?php 
    if ($presort == 'pid') {
        echo 'class="current"';
    }
    ?>
><?php 
    _e('Image ID', 'nggallery');
    ?>
</a> |</li>
				<li><a href="<?php 
    echo esc_attr(add_query_arg('presort', 'filename', $base_url));
    ?>
" <?php 
    if ($presort == 'filename') {
        echo 'class="current"';
    }
    ?>
><?php 
    _e('Filename', 'nggallery');
    ?>
</a> |</li>
				<li><a href="<?php 
    echo esc_attr(add_query_arg('presort', 'alttext', $base_url));
    ?>
" <?php 
    if ($presort == 'alttext') {
        echo 'class="current"';
    }
    ?>
><?php 
    _e('Alt/Title text', 'nggallery');
    ?>
</a> |</li>
				<li><a href="<?php 
    echo esc_attr(add_query_arg('presort', 'imagedate', $base_url));
    ?>
" <?php 
    if ($presort == 'imagedate') {
        echo 'class="current"';
    }
    ?>
><?php 
    _e('Date/Time', 'nggallery');
    ?>
</a> |</li>
				<li><a href="<?php 
    echo esc_attr(add_query_arg('dir', 'ASC', $base_url));
    ?>
" <?php 
    if ($dir == 'ASC') {
        echo 'class="current"';
    }
    ?>
><?php 
    _e('Ascending', 'nggallery');
    ?>
</a> |</li>
				<li><a href="<?php 
    echo esc_attr(add_query_arg('dir', 'DESC', $base_url));
    ?>
" <?php 
    if ($dir == 'DESC') {
        echo 'class="current"';
    }
    ?>
><?php 
    _e('Descending', 'nggallery');
    ?>
</a></li>
			</ul>
		</form>
		<div id="debug" style="clear:both"></div>
		<div class='jqui-sortable'>
			<?php 
    if ($picturelist) {
        foreach ($picturelist as $picture) {
            ?>
					<div class="imageBox" id="pid-<?php 
            echo $picture->pid;
            ?>
">
						<div class="imageBox_theImage" style="background-image:url('<?php 
            echo nextgen_esc_url($picture->thumbURL);
            ?>
')"></div>
						<div class="imageBox_label"><span><?php 
            echo esc_html(stripslashes($picture->alttext));
            ?>
</span></div>
					</div>
					<?php 
        }
    }
    ?>
		</div>
	</div>

<?php 
}