Forum Replies Created

Viewing 9 replies - 1 through 9 (of 9 total)
  • Ricardo Correia

    (@ricardocorreia)

    Hi igor, sure.
    Here’s the code of my simple plugin that solves the issue:

    remove_action( 'wp', 'ai_wp_hook' );
    
    function foundry_ai_wp_hook () {
      global $ai_wp_data, $ai_db_options_extract;
    
      if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_PROCESSING) != 0) ai_log ("WP HOOK START");
      set_page_type ();
      set_user ();
    
      if ($ai_wp_data [AI_WP_PAGE_TYPE] != AI_PT_ADMIN && ($ai_wp_data [AI_WP_USER] & AI_USER_ADMINISTRATOR) != 0 && get_admin_toolbar_debugging ())
        add_action ('admin_bar_menu', 'ai_toolbar', 20);
    
      $url_debugging = get_remote_debugging () || ($ai_wp_data [AI_WP_USER] & AI_USER_ADMINISTRATOR) != 0;
    
      if (!is_admin()) {
        if (isset ($_GET [AI_URL_DEBUG]) && $_GET [AI_URL_DEBUG] == 0) {
          unset ($_COOKIE ['AI_WP_DEBUGGING']);
          setcookie ('AI_WP_DEBUGGING', '', time() - (15 * 60), COOKIEPATH);
          unset ($_COOKIE ['AI_WP_DEBUG_BLOCK']);
          setcookie ('AI_WP_DEBUG_BLOCK', '', time() - (15 * 60), COOKIEPATH);
        } else {
            $ai_wp_data [AI_WP_DEBUGGING]   = isset ($_COOKIE ['AI_WP_DEBUGGING'])   ? $ai_wp_data [AI_WP_DEBUGGING] | ($_COOKIE ['AI_WP_DEBUGGING'] & ~AI_DEBUG_PROCESSING) : $ai_wp_data [AI_WP_DEBUGGING];
            $ai_wp_data [AI_WP_DEBUG_BLOCK] = isset ($_COOKIE ['AI_WP_DEBUG_BLOCK']) ? $_COOKIE ['AI_WP_DEBUG_BLOCK'] : 0;
    
            if (isset ($_GET [AI_URL_DEBUG_BLOCKS]))
              if ($_GET [AI_URL_DEBUG_BLOCKS] && $url_debugging) $ai_wp_data [AI_WP_DEBUGGING] |= AI_DEBUG_BLOCKS; else $ai_wp_data [AI_WP_DEBUGGING] &= ~AI_DEBUG_BLOCKS;
    
            if (isset ($_GET [AI_URL_DEBUG_TAGS]))
              if ($_GET [AI_URL_DEBUG_TAGS] && $url_debugging) $ai_wp_data [AI_WP_DEBUGGING] |= AI_DEBUG_TAGS; else $ai_wp_data [AI_WP_DEBUGGING] &= ~AI_DEBUG_TAGS;
    
            if (isset ($_GET [AI_URL_DEBUG_NO_INSERTION]))
              if ($_GET [AI_URL_DEBUG_NO_INSERTION] && $url_debugging) $ai_wp_data [AI_WP_DEBUGGING] |= AI_DEBUG_NO_INSERTION; else $ai_wp_data [AI_WP_DEBUGGING] &= ~AI_DEBUG_NO_INSERTION;
    
            if (isset ($_GET [AI_URL_DEBUG_POSITIONS])) {
              if ($_GET [AI_URL_DEBUG_POSITIONS] !== '' && $url_debugging) $ai_wp_data [AI_WP_DEBUGGING] |= AI_DEBUG_POSITIONS; else $ai_wp_data [AI_WP_DEBUGGING] &= ~AI_DEBUG_POSITIONS;
              if (is_numeric ($_GET [AI_URL_DEBUG_POSITIONS])) $ai_wp_data [AI_WP_DEBUG_BLOCK] = intval ($_GET [AI_URL_DEBUG_POSITIONS]);
              if ($ai_wp_data [AI_WP_DEBUG_BLOCK] < 0 || $ai_wp_data [AI_WP_DEBUG_BLOCK] > AD_INSERTER_BLOCKS) $ai_wp_data [AI_WP_DEBUG_BLOCK] = 0;
            }
    
            if ($ai_wp_data [AI_WP_DEBUGGING] != 0)
              setcookie ('AI_WP_DEBUGGING',   $ai_wp_data [AI_WP_DEBUGGING],   time() + AI_COOKIE_TIME, COOKIEPATH);
            if ($ai_wp_data [AI_WP_DEBUG_BLOCK] != 0)
              setcookie ('AI_WP_DEBUG_BLOCK', $ai_wp_data [AI_WP_DEBUG_BLOCK], time() + AI_COOKIE_TIME, COOKIEPATH);
          }
      }
    
      $debug_positions             = ($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_POSITIONS) != 0;
      $debug_tags_positions        = ($ai_wp_data [AI_WP_DEBUGGING] & (AI_DEBUG_POSITIONS | AI_DEBUG_TAGS)) != 0;
      $debug_tags_positions_blocks = ($ai_wp_data [AI_WP_DEBUGGING] & (AI_DEBUG_POSITIONS | AI_DEBUG_TAGS | AI_DEBUG_BLOCKS)) != 0;
    
      $plugin_priority = get_plugin_priority ();
      if (isset ($ai_db_options_extract [CONTENT_HOOK_BLOCKS][$ai_wp_data [AI_WP_PAGE_TYPE]]) && count ($ai_db_options_extract [CONTENT_HOOK_BLOCKS][$ai_wp_data [AI_WP_PAGE_TYPE]]) != 0 || $debug_tags_positions)
        add_filter ('the_content',        'ai_content_hook', $plugin_priority);
    
      if (isset ($ai_db_options_extract [EXCERPT_HOOK_BLOCKS][$ai_wp_data [AI_WP_PAGE_TYPE]]) && count ($ai_db_options_extract [EXCERPT_HOOK_BLOCKS][$ai_wp_data [AI_WP_PAGE_TYPE]]) != 0 || $debug_tags_positions_blocks)
        add_filter ('the_excerpt',        'ai_excerpt_hook', $plugin_priority);
    
      if (isset ($ai_db_options_extract [LOOP_START_HOOK_BLOCKS][$ai_wp_data [AI_WP_PAGE_TYPE]]) && count ($ai_db_options_extract [LOOP_START_HOOK_BLOCKS][$ai_wp_data [AI_WP_PAGE_TYPE]]) != 0 || $debug_positions)
        add_action ('loop_start',         'ai_loop_start_hook');
    
      if (isset ($ai_db_options_extract [LOOP_END_HOOK_BLOCKS][$ai_wp_data [AI_WP_PAGE_TYPE]]) && count ($ai_db_options_extract [LOOP_END_HOOK_BLOCKS][$ai_wp_data [AI_WP_PAGE_TYPE]]) != 0 || $debug_positions)
        add_action ('loop_end',           'ai_loop_end_hook');
    
      if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_PROCESSING) != 0) ai_log ("WP HOOK END\n");
    };
    
    add_action( 'wp', 'foundry_ai_wp_hook' );
    
    Ricardo Correia

    (@ricardocorreia)

    Hi Igor,

    I’ve spent a couple of time working on checking things to allow cache on pagely using your plugin in a client website.

    As you stated you’re removing the cookies when !is_admin(), this is correct, but pagely still detects the header cookies and disables caching on the website.

    The way to solve this would be to remove_action() the debugging functions from ‘wp’ when debug mode is off.

    I’ve managed to make this work creating a small plugin to remove your hook. But I think it would be good to have this in your code when debug is off.

    Thanks

    True that’s why I think this isn’t the proper solution but it works, just want to bring to your attention that the fix it’s the other way around, it doesn’t allow to return earlier when it’s in terms page.

    The original function:

    /**
     * Returns the object type
     * @since  1.0.0
     * @return string Object type
     */
    public function object_type( $object_type = '' ) {
    
    	if ( $object_type ) {
    		$this->object_type = $object_type;
    		return $this->object_type;
    	}
    		
    	if ( $this->object_type ) {
    		return $this->object_type;
    	}
    	
    	$this->object_type = $this->current_object_type();
    
    	return $this->object_type;
    }

    Also, this is something that doesn’t happen in every project I’ve used CMB2 for terms meta, it only happened in this one.

    Having another go at this bug I’ve notice that the “options page” fields weren’t displayed when the object_type attribution is commented out.
    I’ve fix this issue by adding a check for the current admin page also in this function.

    /**
     * Returns the object type
     * @since  1.0.0
     * @return string Object type
     */
    public function object_type( $object_type = '' ) {
    
    	if ( $object_type ) {
    		$this->object_type = $object_type;
    		return $this->object_type;
    	}
    
    	global $pagenow;
    		
    	if ( 'term.php' !== $pagenow ) {
    		if ( $this->object_type ) {
    			return $this->object_type;
    		}
    	}
    
    	$this->object_type = $this->current_object_type();
    
    	return $this->object_type;
    }

    Didn’t submitted an issue and PR for this in the repo because I’m not totally sure what’s causing this bug to happen.

    Just had the same issue and commenting that line solved it.

    From what I understood object_type is not defined when entering that function and so it assumes the default value “post”.

    Tried to see where it’s not being correctly processed as the fields are shown and only the values aren’t but no luck so far.

    Thread Starter Ricardo Correia

    (@ricardocorreia)

    I’m testing this situation in a different network and machines, and the problem doesn’t occur.

    I’m starting to think that the problem is on browser or network caching. I’m still figuring out if the previous tested network has it activated.

    Thread Starter Ricardo Correia

    (@ricardocorreia)

    Not really, I’m viewing the drafts in other browser with a “incognito window” I’m not logged in or have the post in cache.

    I’ve tried this in 2 different websites at 2 different servers.

    Any ideas?

    I’ve done some testing and I’ve noticed that none of the AddThis js are loaded once the SEO is active. I haven’t been able to figure out why.

    Thanks for any help in this matter.

    I’m having the same problem, when WordPress SEO by Yoast plugin the buttons aren’t rendered.

    I’m debugging now to see if i can pinpoint the problem in a accurate form.

Viewing 9 replies - 1 through 9 (of 9 total)