Forum Replies Created

Viewing 15 replies - 1 through 15 (of 19 total)
  • Thank you very much for keeping this plugin active. There is nothing like it that I have found. I’d be happy to contribute a donation to its ongoing development.

    Thanks.

    Thread Starter mwyche

    (@mwyche)

    Thank you! I’ve discovered the cause of my responsive problems, and am using the latest version of Popups.

    Again, great work on this plugin. I appreciate your response.

    I am having the same issue as well on https://www.seeuncharted.com. Any assistance is appreciated.

    I am also running my plugin on Nginx with Pagespeed enabled. Here are my rewrite rules:

    #Pagespeed Location Directives
    
    # Don't cache uris containing the following segments
            if ($request_uri ~* "/wp-admin/|/xmlrpc.php|wp-.*.php|/feed/|/|index.php|sitemap(_index)?.xml") {
                    set $skip_cache 1;
    
    #Yoast sitemap
    location ~ ([^/]*)sitemap(.*)\.x(m|s)l$ {
            ## this redirects sitemap.xml to /sitemap_index.xml
            rewrite ^/sitemap\.xml$ /sitemap_index.xml permanent;
            ## this makes the XML sitemaps work
            rewrite ^/([a-z]+)?-?sitemap\.xsl$ /index.php?xsl=$1 last;
            rewrite ^/sitemap_index\.xml$ /index.php?sitemap=1 last;
            rewrite ^/([^/]+?)-sitemap([0-9]+)?\.xml$ /index.php?sitemap=$1&sitemap_n=$2 last;
            }

    Is there anything that can be done to have work continue on this app? I am willing to contribute funding toward maintaining development activity on it.

    Thanks.

    @caspianjvc, thanks for the tip. Glad to see it working. I think I like it better with this config.

    Cheers!

    I’m having the same issue that others have reported. Very disappointing to see that this plugin has been abandoned. It is quite unique relative to other plugins of its type.

    Yes, I tried. It resolved the white screen issue after posting a comment. But, it causes my home page slider to disappear.

    Note, I did not implement the debug code you supplied, because I wasn’t sure if you wanted the code to go within this line, or above it:

    if ( ( $credentials = request_filesystem_credentials( ” ) ) === false )

    Please clarify.

    Thank you.

    I’m experiencing the same issue on my site https://www.seeuncharted.com. I have tried implemented the code you suggested, but it does not work.

    Here is the code in my nginx-cache.php file

    <?php
    /*
    Plugin Name: Nginx Cache
    Plugin URI: https://www.ads-software.com/plugins/nginx-cache/
    Description: Flush the Nginx cache (FastCGI, Proxy, uWSGI) automatically when content changes or manually within WordPress.
    Version: 1.0
    Text Domain: nginx-cache
    Domain Path: /languages
    Author: Till Krüss
    Author URI: https://till.kruss.me/
    License: GPLv3
    License URI: https://www.gnu.org/licenses/gpl-3.0.html
    */
    
    if ( ! defined( 'ABSPATH' ) ) exit;
    
    class NginxCache {
    
    	private $screen = 'tools_page_nginx-cache';
    	private $capability = 'manage_options';
    	private $admin_page = 'tools.php?page=nginx-cache';
    
    	public function __construct() {
    
    		load_plugin_textdomain( 'nginx-cache', false, 'nginx-cache/languages' );
    
    		add_filter( 'option_nginx_cache_path', 'sanitize_text_field' );
    		add_filter( 'option_nginx_auto_flush', 'absint' );
    		add_filter( 'plugin_action_links_' . plugin_basename( __FILE__ ), array( $this, 'add_plugin_actions_links' ) );
    
    		add_action( 'admin_init', array( $this, 'register_settings' ) );
    		add_action( 'admin_menu', array( $this, 'add_admin_menu_page' ) );
    		add_action( 'admin_bar_menu', array( $this, 'add_admin_bar_node' ), 100 );
    		add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_admin_styles' ) );
    		add_action( 'load-' . $this->screen, array( $this, 'do_admin_actions' ) );
    		add_action( 'load-' . $this->screen, array( $this, 'add_settings_notices' ) );
    
    		// use <code>nginx_cache_flush_actions</code> filter to alter default flush actions
    		$flush_actions = (array) apply_filters(
    			'nginx_cache_flush_actions',
    			array(
    				'publish_phone', 'save_post', 'edit_post', 'delete_post', 'wp_trash_post', 'clean_post_cache',
    				'trackback_post', 'pingback_post', 'comment_post', 'edit_comment', 'delete_comment', 'wp_set_comment_status',
    				'switch_theme', 'wp_update_nav_menu', 'edit_user_profile_update'
    			)
    		);
    
    		foreach ( $flush_actions as $action ) {
    			add_action( $action, array( $this, 'flush_zone_once' ) );
    		}
    
    	}
    
    	public function register_settings() {
    
    		register_setting( 'nginx-cache', 'nginx_cache_path', 'sanitize_text_field' );
    		register_setting( 'nginx-cache', 'nginx_auto_flush', 'absint' );
    
    	}
    
    	public function add_settings_notices() {
    
    		$path_error = $this->is_valid_path();
    
    		if ( isset( $_GET[ 'message' ] ) && ! isset( $_GET[ 'settings-updated' ] ) ) {
    
    			// show cache flush success message
    			if ( $_GET[ 'message' ] === 'cache-flushed' ) {
    				add_settings_error( '', 'nginx_cache_path', __( 'Cache flushed.', 'nginx-cache' ), 'updated' );
    			}
    
    			// show cache flush failure message
    			if ( $_GET[ 'message' ] === 'flush-cache-failed' ) {
    				add_settings_error( '', 'nginx_cache_path', sprintf( __( 'Cache could not be flushed. %s', 'nginx-cache' ), wptexturize( $path_error->get_error_message() ) ) );
    			}
    
    		} elseif ( is_wp_error( $path_error ) && $path_error->get_error_code() === 'fs' ) {
    
    			// show cache path problem message
    			add_settings_error( '', 'nginx_cache_path', wptexturize( $path_error->get_error_message( 'fs' ) ) );
    
    		}
    
    	}
    
    	public function do_admin_actions() {
    
    		// flush cache
    		if ( isset( $_GET[ 'action' ] ) && $_GET[ 'action' ] === 'flush-cache' && wp_verify_nonce( $_GET[ '_wpnonce' ], 'flush-cache' ) ) {
    
    			$result = $this->flush_zone();
    			wp_safe_redirect( admin_url( add_query_arg( 'message', is_wp_error( $result ) ? 'flush-cache-failed' : 'cache-flushed', $this->admin_page ) ) );
    			exit;
    
    		}
    
    	}
    
    	public function add_admin_bar_node( $wp_admin_bar ) {
    
    		// verify user capability
    		if ( ! current_user_can( $this->capability ) ) {
    			return;
    		}
    
    		// add "Nginx" node to admin-bar
    		$wp_admin_bar->add_node( array(
    			'id' => 'nginx-cache',
    			'title' => __( 'Nginx', 'nginx-cache' ),
    			'href' => admin_url( $this->admin_page )
    		) );
    
    		// add "Flush Cache" to "Nginx" node
    		$wp_admin_bar->add_node( array(
    			'parent' => 'nginx-cache',
    			'id' => 'flush-cache',
    			'title' => __( 'Flush Cache', 'nginx-cache' ),
    			'href' => wp_nonce_url( admin_url( add_query_arg( 'action', 'flush-cache', $this->admin_page ) ), 'flush-cache' )
    		) );
    
    	}
    
    	public function add_admin_menu_page() {
    
    		// add "Tools" sub-page
    		add_management_page(
    			__( 'Nginx Cache', 'nginx-cache' ),
    			__( 'Nginx', 'nginx-cache' ),
    			$this->capability,
    			'nginx-cache',
    			array( $this, 'show_settings_page' )
    		);
    
    	}
    
    	public function show_settings_page() {
    		require_once plugin_dir_path( __FILE__ ) . '/includes/settings-page.php';
    	}
    
    	public function add_plugin_actions_links( $links ) {
    
    		// add settings link to plugin actions
    		return array_merge(
    			array( '<a href="' . admin_url( $this->admin_page ) . '">Settings</a>' ),
    			$links
    		);
    
    	}
    
    	public function enqueue_admin_styles( $hook_suffix ) {
    
    		if ( $hook_suffix === $this->screen ) {
    			$plugin = get_plugin_data( __FILE__ );
    			wp_enqueue_style( 'nginx-cache', plugin_dir_url( __FILE__ ) . 'includes/settings-page.css', null, $plugin[ 'Version' ] );
    		}
    
    	}
    
    	private function is_valid_path() {
    
    		global $wp_filesystem;
    
    		$path = get_option( 'nginx_cache_path' );
    
    		if ( empty( $path ) ) {
    			return new WP_Error( 'empty', __( '"Cache Zone Path" is not set.', 'nginx-cache' ) );
    		}
    
    		if ( $this->initialize_filesystem() ) {
    
    			if ( ! $wp_filesystem->exists( $path ) ) {
    				return new WP_Error( 'fs', __( '"Cache Zone Path" does not exist.', 'nginx-cache' ) );
    			}
    
    			if ( ! $wp_filesystem->is_dir( $path ) ) {
    				return new WP_Error( 'fs', __( '"Cache Zone Path" is not a directory.', 'nginx-cache' ) );
    			}
    
    			$list = $wp_filesystem->dirlist( $path, true, true );
    			if ( ! $this->validate_dirlist( $list ) ) {
    				return new WP_Error( 'fs', __( '"Cache Zone Path" does not appear to be a Nginx cache zone directory.', 'nginx-cache' ) );
    			}
    
    			if ( ! $wp_filesystem->is_writable( $path ) ) {
    				return new WP_Error( 'fs', __( '"Cache Zone Path" is not writable.', 'nginx-cache' ) );
    			}
    
    			return true;
    
    		}
    
    		return new WP_Error( 'fs', __( 'Filesystem API could not be initialized.', 'nginx-cache' ) );
    
    	}
    
    	private function validate_dirlist( $list ) {
    
    		foreach ( $list as $item ) {
    
    			// abort if file is not a MD5 hash
    			if ( $item[ 'type' ] === 'f' && ( strlen( $item[ 'name' ] ) !== 32 || ! ctype_xdigit( $item[ 'name' ] ) ) ) {
    				return false;
    			}
    
    			// validate subdirectories recursively
    			if ( $item[ 'type' ] === 'd' && ! $this->validate_dirlist( $item[ 'files' ] ) ) {
    				return false;
    			}
    
    		}
    
    		return true;
    
    	}
    
    	public function flush_zone_once() {
    
    		static $completed = false;
    
    		if ( ! $completed ) {
    			$this->flush_zone();
    			$completed = true;
    		}
    
    	}
    
    	private function flush_zone() {
    
    		global $wp_filesystem;
    
    		$path = get_option( 'nginx_cache_path' );
    		$path_error = $this->is_valid_path();
    
    		// abort if cache zone path is not valid
    		if ( is_wp_error( $path_error ) ) {
    			return $path_error;
    		}
    
    		// remove cache directory (recursively)
    		$wp_filesystem->rmdir( $path, true );
    
    		return true;
    
    	}
    
    	private function initialize_filesystem() {
    
    		ob_start(); // buffer output
    
    		if ( ( $credentials = request_filesystem_credentials( '' ) ) === false ) {
    			ob_end_clean(); // prevent display of filesystem credentials form
    			return false;
    		}
    
    		if ( ! WP_Filesystem( $credentials ) ) {
    			return false;
    		}
    
    		return true;
    
    	}
    
    }
    
    new NginxCache;

    Here is the error output from my nginx error log.

    16/01/09 11:55:21 [error] 19850#0: *56348 FastCGI sent in stderr: "PHP message: PHP Fatal error: Call to undefined function request_filesystem_credentials() in /var/www/html/wp-content/plugins/nginx-cache/nginx-cache.php on line 250" while reading response header from upstream, client: 108.162.219.50, server: www.seeuncharted.com, request: "POST /wp-comments-post.php HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "www.seeuncharted.com", referrer: "https://www.seeuncharted.com/countdown-2-days-left/"

    Any assistance wit this issue is very much appreciated.

    Thank you.

    I’m having the same issue. The plugin has worked fine for me until recently.

    I have checked my php log, but there is no indication of an error. Is there something else I should check to determine the cause of this error?

    My website is https://www.seeuncharted.com

    Thank you.

    Thread Starter mwyche

    (@mwyche)

    Resolved.

    Thread Starter mwyche

    (@mwyche)

    Hi Hector

    I got it resolved. Everything is back in working order.

    Just a heads up in case anyone else runs into the same issue.

    Plugin is working as it did before the update.

    Thanks!

    Thread Starter mwyche

    (@mwyche)

    The error message I received after discovering the plugin was missing from my installations and trying to reinstall…

    Destination folder already exists. …/wp-content/plugins/wordpress-popular-posts/

    Plugin install failed.

    Thanks Webber. I understand now. I’ll make the change to max-width.

    Regards.

    Hello Ajay:

    I’m revisiting this again. I’m running a Responsive theme on my website.

    The Top 10 ‘Style’ attribute utilizes the custom thumbnail image dimensions. Is there a way to override this?

    For example, if I specify custom thumbnail dimensions of 375px, but the browser window only accommodates for images up to 335 px, shouldn’t the CSS resize the image according to size of the browser window.

    In one of your previous replies, you proposed the following:

    .tptn_posts_daily ul, .tptn_posts ul {
    display: block;
    margin-left: auto;
    margin-right: auto;
    max-width: 1060px;

    Is the ‘max-width: 1060px;’ accounting for the width of the container or the image size? Based on the Top 10 ‘Style’ attribute setting, this seems to account for the thumbnail size, not the container, unless I am mistaken.

    Any information is very much appreciated.

    Thanks.

Viewing 15 replies - 1 through 15 (of 19 total)