<?php

namespace Elex\MultiVendor;

if ( ! defined( 'ABSPATH' ) ) {
exit;
}

class Deactivate_Multivendor {

	public static function delete_vendor_pages() {

		$posts = get_posts(
			array(
				'post_type'              => 'page',
				'title'                  => 'Vendor Dashboard',
				'post_status'            => 'all',
				'numberposts'            => 1,
				'update_post_term_cache' => false,
				'update_post_meta_cache' => false,           
	
			)
		);
			 
	
		if ( ! empty( $posts ) ) {
			
			wp_delete_post( $posts[0]->ID, true );
		}


		$admin_params = get_option( 'elex_mv_admin_installation_params', false );
		if ( isset( $admin_params['elex_mv_store_slug'] ) && ! empty( $admin_params['elex_mv_store_slug'] ) ) {


			$posts = get_posts(
				array(
					'name'                   => $admin_params['elex_mv_store_slug'],
					'post_type'              => 'page',
					'post_status'            => 'all',
					'numberposts'            => 1,
					'update_post_term_cache' => false,
					'update_post_meta_cache' => false,           
			
				)
			);
					 
			
			if ( ! empty( $posts ) ) {
					
				wp_delete_post( $posts[0]->ID, true );
			}       
		}
	}
}
