Current File : /home/bdmcricketindia.in/public_html/wp-content/plugins/redirection/models/monitor.php
<?php

class Red_Monitor {
	private $monitor_group_id;
	private $updated_posts = array();
	private $monitor_types = array();
	private $associated = '';

	public function __construct( $options ) {
		$this->monitor_types = apply_filters( 'redirection_monitor_types', isset( $options['monitor_types'] ) ? $options['monitor_types'] : array() );

		if ( count( $this->monitor_types ) > 0 && $options['monitor_post'] > 0 ) {
			$this->monitor_group_id = intval( $options['monitor_post'], 10 );
			$this->associated = isset( $options['associated_redirect'] ) ? $options['associated_redirect'] : '';

			// Only monitor if permalinks enabled
			if ( get_option( 'permalink_structure' ) ) {
				add_action( 'pre_post_update', array( $this, 'pre_post_update' ), 10, 2 );
				add_action( 'post_updated', array( $this, 'post_updated' ), 11, 3 );
				add_filter( 'redirection_remove_existing', array( $this, 'remove_existing_redirect' ) );
				add_filter( 'redirection_permalink_changed', array( $this, 'has_permalink_changed' ), 10, 3 );

				if ( in_array( 'trash', $this->monitor_types ) ) {
					add_action( 'wp_trash_post', array( $this, 'post_trashed' ) );
				}
			}
		}
	}

	public function remove_existing_redirect( $url ) {
		Red_Item::disable_where_matches( $url );
	}

	public function can_monitor_post( $post, $post_before ) {
		// Check this is for the expected post
		if ( ! isset( $post->ID ) || ! isset( $this->updated_posts[ $post->ID ] ) ) {
			return false;
		}

		// Don't do anything if we're not published
		if ( $post->post_status !== 'publish' || $post_before->post_status !== 'publish' ) {
			return false;
		}

		$type = get_post_type( $post->ID );
		if ( ! in_array( $type, $this->monitor_types ) ) {
			return false;
		}

		return true;
	}

	/**
	 * Called when a post has been updated - check if the slug has changed
	 */
	public function post_updated( $post_id, $post, $post_before ) {
		if ( isset( $this->updated_posts[ $post_id ] ) && $this->can_monitor_post( $post, $post_before ) ) {
			$this->check_for_modified_slug( $post_id, $this->updated_posts[ $post_id ] );
		}
	}

	/**
	 * Remember the previous post permalink
	 */
	public function pre_post_update( $post_id, $data ) {
		$this->updated_posts[ $post_id ] = get_permalink( $post_id );
	}

	public function post_trashed( $post_id ) {
		$data = array(
			'url'         => wp_parse_url( get_permalink( $post_id ), PHP_URL_PATH ),
			'action_data' => array( 'url' => '/' ),
			'match_type'  => 'url',
			'action_type' => 'url',
			'action_code' => 301,
			'group_id'    => $this->monitor_group_id,
			'status'      => 'disabled',
		);

		// Create a new redirect for this post, but only if not draft
		if ( $data['url'] !== '/' ) {
			Red_Item::create( $data );
		}
	}

	/**
	 * Changed if permalinks are different and the before wasn't the site url (we don't want to redirect the site URL)
	 */
	public function has_permalink_changed( $result, $before, $after ) {
		// Check it's not redirecting from the root
		if ( $this->get_site_path() === $before || $before === '/' ) {
			return false;
		}

		// Are the URLs the same?
		if ( $before === $after ) {
			return false;
		}

		return true;
	}

	private function get_site_path() {
		$path = wp_parse_url( get_site_url(), PHP_URL_PATH );

		if ( $path ) {
			return rtrim( $path, '/' ) . '/';
		}

		return '/';
	}

	public function check_for_modified_slug( $post_id, $before ) {
		$after  = wp_parse_url( get_permalink( $post_id ), PHP_URL_PATH );
		$before = wp_parse_url( esc_url( $before ), PHP_URL_PATH );

		if ( apply_filters( 'redirection_permalink_changed', false, $before, $after ) ) {
			do_action( 'redirection_remove_existing', $after, $post_id );

			$data = array(
				'url'         => $before,
				'action_data' => array( 'url' => $after ),
				'match_type'  => 'url',
				'action_type' => 'url',
				'action_code' => 301,
				'group_id'    => $this->monitor_group_id,
			);

			// Create a new redirect for this post
			$new_item = Red_Item::create( $data );

			if ( ! is_wp_error( $new_item ) ) {
				do_action( 'redirection_monitor_created', $new_item, $before, $post_id );

				if ( ! empty( $this->associated ) ) {
					// Create an associated redirect for this post
					$data['url'] = trailingslashit( $data['url'] ) . ltrim( $this->associated, '/' );
					$data['action_data'] = array( 'url' => trailingslashit( $data['action_data']['url'] ) . ltrim( $this->associated, '/' ) );
					Red_Item::create( $data );
				}
			}

			return true;
		}

		return false;
	}
}
BDM Cricket India: tips, teams, tournaments

Recent Posts

Apostas Desportivas Site De Apostas Vave Online Bónus

“Sign In Mostbet Guia Content Entrar No Website Oficial Programa De Afiliados Da Mosbet No Brasil Stáhnout Soubor Apk Pro Android Benefícios Exclusivos Pra Brasileiros Bônus Elizabeth Promoções Mais Atraentes Usabilidade Da Plataforma Como Faço Para Hacer O Aplicativo Mostbet Em Meu Dispositivo Android? Programa Sobre Bônus Da Mostbet No …

Read More »

Beginner’s Facts Casino Betting: Tips & Strategies

How To Play Slots And Even Win Big Understand Online Slots Content Best Games & Strategies To Earn Money Casino Betting: The Entire Guide For Beginners Best Free Spins Casino Uk – Sky Vegas Multiple Paylines Practice With Free Games Understand The Way To Play Your Slot Find Alternatives To …

Read More »

Отнесение к разряду интерактивный казино в 2025 топ-десял намного лучших веб сайтов в видах игры нате действительные аржаны, благонадежные обзоры

А как промахнуться во западней а еще выбрать истинное аптерия для игры в онлайн игорный дом объективные деньги? Регистрация получите и распишитесь ненадежной площадке сопряжена с рисками. Эти операторы нередко обманывают инвесторов, заблокируют их учетные календарь, задерживают выплаты. Вдобавок они могут воздействовать нате норма занятия слотов, вероломствуя барыш отдачи в …

Read More »

Laissez-vous ensorceler par lunivers fascinant de Win Unique Wiz !

Laissez-vous ensorceler par lunivers fascinant de Win Unique Wiz ! Plongée dans l’univers des jeux en ligne Les machines à sous révélatrices Les jeux de table : tradition et stratégie Les bonus et promotions La sécurité des joueurs L’impact des technologies modernes La mobile gaming L’importance du soutien client Les …

Read More »

CASHlib Casinos in Deutschland – Was bieten sie?

CASHlib Casinos gewinnen in Deutschland immer mehr an Bedeutung. Diese Casinos ermöglichen es Spielern, anonym und sicher mit Prepaid-Guthaben zu bezahlen – ganz ohne Bankverbindung oder Kreditkarte. Besonders für Nutzer, die auf Datenschutz und schnelle Transaktionen Wert legen, sind sie eine interessante Alternative.

Was bieten CASHlib Casinos?

  • Schnelle und anonyme Einzahlungen ohne Registrierung bei Drittanbietern
  • Breites Spielangebot von Slots bis zu Live-Dealer-Spielen
  • Regelmäßige Aktionen wie Freispiele und Cashback
  • Attraktive Willkommensboni für neue Spieler
  • EU-lizenzierte Anbieter mit hohen Sicherheitsstandards

Ein großer Vorteil von CASHlib ist, dass keine sensiblen Bankdaten im Casino hinterlegt werden müssen. Die Gutscheine sind online oder in vielen Verkaufsstellen erhältlich und können sofort verwendet werden. Dadurch entfällt auch die Notwendigkeit, persönliche Daten bei Einzahlungen preiszugeben – ein echter Pluspunkt für sicherheitsbewusste Spieler.

Viele spielothekgermany.com/de/spielothek/cashlib-casinos/ bieten zudem mobile Kompatibilität, einfache Menüführung und professionellen Spielerschutz. Wer nach einem unkomplizierten Zahlungsweg mit solider Auswahl an Spielen und Bonusangeboten sucht, wird bei diesen Plattformen fündig. Die Kombination aus Bequemlichkeit, Sicherheit und einem attraktiven Bonusangebot macht CASHlib Casinos zu einer beliebten Wahl für deutsche Nutzer.

slot 7