• Resolved idonteatmeat

    (@idonteatmeat)


    Hi,

    I installed Complianz and am not sure what I did wrong but the plugin generated 1900 pages of “Cookie-Richtlinie (UK)”.

    I am very sorry to bother you and really don’t know what I did wrong despite running your wizard. You have any Idea? Also – HOW DO I GET RID OF THEM! HELP!

    Thank you.

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Contributor Rogier Lankhorst

    (@rogierlankhorst)

    Hi @idonteatmeat,

    I’m sorry to hear you’re having this weird issue! It appears that somehow the plugin does not recognize the existing pages as having the shortcode, and keeps adding it.

    Possibly a specific plugin is causing a compatibility issue, I haven’t seen this before.

    First, I’ll write a short function that will clean up the pages for you. I think I can have it tested and posted here in an hour or so, I’ll get back to you asap.

    Plugin Contributor Rogier Lankhorst

    (@rogierlankhorst)

    Do these pages contain the Complianz shortcode? Or if you’re using Gutenberg, do they contain the Complianz Gutenberg block?

    If so, the code below will remove all pages with the UK cookie policy shortcode. If not, I can make you a function that looks at the title, let me know. You can add the code in your theme’s functions.php and remove it after it has run (a page refresh).

    function cmplz_cleanup(){
    	$type = 'cookie-statement-uk';
    	$shortcode = 'cmplz-document';
    
    	$args = array(
    		'number' => '200',
    	);
    	$pages = get_pages($args);	foreach ($pages as $page) {
    		$post_meta = get_post_meta($page->ID, 'cmplz_shortcode',true);
    		if ($post_meta) {
    			$html = $post_meta;
    		} else {
    			$html = $page->post_content;
    		}
    		delete_transient('cmplz_shortcode_' . $type);
    
    		/*
    		 * Gutenberg block check
    		 *
    		 * */
    		//check if block contains property
    		if (preg_match('/"selectedDocument":"(.*?)"/i', $html, $matches)) {
    			if ($matches[1]===$type) {
    				wp_delete_post( $page->ID, true);
    				continue;
    			}
    		}
    
    		/*
    		 * If nothing found, or if not Gutenberg, check for shortcodes.
    		 * Classic shortcode check
    		 *
    		 * */
    
    		if (has_shortcode($html, $shortcode) && strpos($html, 'type="' . $type.'"')!==FALSE) {
    			wp_delete_post( $page->ID, true);
    		}
    	}
    }
    add_action('admin_init', 'cmplz_cleanup');
    Thread Starter idonteatmeat

    (@idonteatmeat)

    Wow, how kind of you. Thank you very much.

    I don’t know what happened either. It happened at the 3rd Dec. The day I activated the plugin and ran the wizard. So it’s hard for me to replicate.

    I just noticed the pages today as I took a look at the page list.

    No new once got created since then. So simply a function to get rid of them would be really awesome. I have access to functions.php.

    Thank you for your help

    • This reply was modified 5 years, 2 months ago by idonteatmeat.
    Plugin Contributor Rogier Lankhorst

    (@rogierlankhorst)

    @idonteatmeat I’ve made a small adjustment, limiting the number of pages in one call to 200, otherwise you can get a time out, because most servers limit a php execution to 30 s, and 1900 is a lot of pages to process.

    Thread Starter idonteatmeat

    (@idonteatmeat)

    Thank you so much. That worked. I’m really impressed. Never had such a short response time from a developer. Thank you very much. I left you a 5 Star rating and some kind words.

    • This reply was modified 5 years, 2 months ago by idonteatmeat.
    Plugin Contributor Rogier Lankhorst

    (@rogierlankhorst)

    Great! And thanks for the review ??

    This will have removed all cookie policy pages, so you will need to create one again.

    After you removed the cleanup code you can add a page, with [cmplz-document type=”cookie-statement-uk”] in the editor (classic), or if you use Gutenberg add a Complianz Gutenberg block, then select “Cookie Policy UK” from the dropdown list.

    When that’s finished, you should be set.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Compliance created 1900 Cookie Notices Pages’ is closed to new replies.