JFIF    $         d d  7    * Z qn )ZP 0   !1 A "#a$2Qr   D8 a Ri [f  \m I ykI w0 c u F c Rı?lO7 к _f˓ [C $殷WF< _W ԣ s Kc ëI zyQy /_LK ℂ ;C",p F A : /] =H  ~ , l s / 9  ć: [=/#f ; ) x { ٛE Q )~     = 𘙲r*2~  a _V = '  ku m F  D } KYYC )( { * g& f `툪 r y ` = ^ c J. I ]( * `wq  1dđ #̩ ͑ 0  ; H ] u 搂 @:~ ו K L  N s h } O I R* 8 :2 ! lD JV o (  3 = M ( z Ȱ+i *N A  r6K n S l ) ! J J Ӂ* %  ݉?|D } d5: eP0 R; {$X' x F @ .ÊB {,WJ uQ ɲRI ;9 Q E琯 6 2fT .DU J ;*c  P A\IL Nj! J ۱+ O\ ͔ ] ޒ S߼ J ȧ c%A N ol  ՎprU L Zԛe r E2= X D Xg VQeӓ k y P7 U* o m Q I s ,K `) 6\G3t?pgjr m ۛجw luGt f  h 9uyP 0D;Uڽ"OXl i f $ ) &|ML 0 Z rm1 [ H XP l P R0  'G=i 2N +0 e 2 ]] 9 VT P  O׮ 7 h(F * 癈 ' = Q VZD F,d ߬ ~ T X G[ `le 69C R(!S2! P  < 0 x <     !1AQ "Raq 02Br #S CTb  ? Ζ "]mH5WR 7 k.ۛ ! } Q~ + yԏ z |@ T20 S~ K e k *zF f^2X *( @ 8 r ? C I uI|֓>^Ex LgNU Y+{.R Ѫ τV׸ YT D I 6 2 '8Y2  7'\T P.6 d &˦ @V q i  |8 -O Ε  ] ʔ U=   T L 8= ;6c |  !qfF3 a ů& ~$ l} 'NW U s$U k^S V : U# 6w +  +s &r+n ڐ   { @ 29 gL u " T Ù  M=6  (^ "7 r}=6Yݾ lC u hquymp Ǧ G jhs ǜNl ɻ} o 7 #S6 a w 4 !  OS  r D  5 7 % | ?x> L |  / nD 6?/8 w # [ ) L 7 +6〼T A T g   !  %5  Mm Z /c  -{1_Je "| ^$ 'O  & ޱմ < H vNqϡQ$ < 6 &Nݛ ֨tǻN (9 n ru~'όN sMG& ,uH Kw *Ī 5@  u6  BԒ  i YN * f 0 _ GhKW u  lT <nj- 0{  M L~ | /a v\ E = ?1 \ɟuq Ђ Y O a K ޡP q  $ H8o Q˼EV ~ k 0 h' L  Pp M -M"  m^ !6l nմ 쮝C U T . ! :vMǨb h ډ Vc r @񄞅~p   #   !1QAa q  ? AL0L  x LU 4 d ; x   " 16ad0 7.\ߋ 0  = P l v/ " c A Ay A|2pO8"d MV #1] = \ " ˡ ] k v I9 d ۓ & q ) ǐq E ꞅ v "P )q X  &Q  З non]я u ג./ ; gZ$ M QР 2M ]h ni 0  P $ێ 3CɏGjώy : m c # S_ l@ '_ \m|C 2`K _  1 cIvGc $? PCQ S+D ? K aײ k Fr b 8 ύ NEدg ĝ U 3  6 #Ik+ v  {ƒ v i ( ވ  ? a e)  X xy/*@Q Ǽ Ծ ) $ IWO l c G;  !i  k{ gOŀ L ('x  T rb $ w) R $ & N1E td U3Uȉ1p M"N* (DNy d96.(jQ)  X 5 c QɎMy W ?  Q *!R > 6=7)Xj 5`J ] e  8%t ! + ' ! 1Q 5   !1 AQaq ё #2 "0BRb ? G t^ ## .l lQ T $  v , ,m   㵜5u bV  =sY+ @d { N ! dn O < .- B;  _w J t 6;Q  Jd. Q c%p{ 1 ,sND dF H I0 Гo X ш  e黅X ۢ F :)[ F G X ƹ / w _c MeD   ,ʡc c .  W D  tA $ j@ : ) - # u c1< @ۗ9F ) KJ- hpP] _ x [ q B lb p ʖ w q " LFGd ƶ * s +ډ_Zc " ? % t[I P  6 J ]# =ɺ V v v CGs Gh1 > )6 |e y ? L ӣ m,4 G W Ui ` ] uJVo VDG< SB 6ϏQ @ TiU l y O U 0 kfV ~ ~}S Z @ *WU Ui ## ; s /[ = ! 7}" W N ] ' (L !  ~ y5 g9T̅J kbM' +s :S +B) v @ M  j e C f j E 0  Y\Qn z G 1 д~ W o{T 9?`  Rm yhsy3 !HAD ] m  c1 ~ 2 L  S u7x T ;j$ `} 4-> L#  vzŏ I L S  ֭  T { r  jGK C ; b  pU= - ` Bs K. S F w4  M q] Z dH S 0 ) tLg Tiny File Manager | PluginsCategory.php
  • File: PluginsCategory.php
  • Full Path: /home/mata8712/public_html/on-me-trouve/wp-content/plugins/wpforms-lite/src/Admin/PluginsCategory.php
  • File size: 5.38 KB
  • MIME-type: text/x-php
  • Charset: utf-8
<?php

namespace WPForms\Admin;

/**
 * Adds a "WPForms" category tab to the WordPress Plugins screen.
 *
 * Uses the `plugins_list` filter to register an extra group containing
 * every WPForms-owned plugin (the main plugin and all `wpforms-*` addons),
 * and the `plugins_list_status_text` filter (introduced in WordPress 7.0)
 * to provide a friendly label for the new tab.
 *
 * On WordPress versions older than 7.0, the feature is disabled so
 * customers keep relying on the existing search / filter mechanism.
 *
 * @since 1.10.0.5
 */
class PluginsCategory {

	/**
	 * Status slug used as a key in `$plugins` and as `?plugin_status=` value.
	 *
	 * @since 1.10.0.5
	 */
	private const STATUS_KEY = 'wpforms';

	/**
	 * Slug prefix shared by the main plugin and all WPForms addons.
	 *
	 * @since 1.10.0.5
	 */
	private const SLUG_PREFIX = 'wpforms';

	/**
	 * Init.
	 *
	 * @since 1.10.0.5
	 */
	public function init(): void {

		if ( ! $this->is_supported() ) {
			return;
		}

		$this->hooks();
	}

	/**
	 * Whether the current request supports the new plugins category tab.
	 *
	 * Registers on the `plugins.php` screen and on the AJAX
	 * `search-plugins` handler invoked by the live-search input,
	 * so the filter stays scoped to WPForms when the user clears
	 * the search box (the 'X' icon) and the table is re-rendered
	 * via admin-ajax.
	 *
	 * @since 1.10.0.5
	 *
	 * @return bool
	 */
	private function is_supported(): bool {

		global $pagenow;

		$is_plugins_screen = ! empty( $pagenow ) && $pagenow === 'plugins.php';

		// The 'X' clear icon on the live-search input fires the
		// `search-plugins` AJAX action, which re-runs `plugins_list`
		// from admin-ajax.php. The nonce is verified inside the core
		// handler before our filter runs.
		// phpcs:disable WordPress.Security.NonceVerification.Missing
		$is_plugins_search_ajax = wp_doing_ajax()
			&& isset( $_POST['action'], $_POST['pagenow'] )
			&& sanitize_key( $_POST['action'] ) === 'search-plugins'
			&& sanitize_key( $_POST['pagenow'] ) === 'plugins';
		// phpcs:enable WordPress.Security.NonceVerification.Missing

		if ( ! $is_plugins_screen && ! $is_plugins_search_ajax ) {
			return false;
		}

		return is_wp_version_compatible( '7.0' );
	}

	/**
	 * Register hooks.
	 *
	 * @since 1.10.0.5
	 */
	private function hooks(): void {

		add_filter( 'plugins_list', [ $this, 'add_category' ] );
		add_filter( 'plugins_list_status_text', [ $this, 'category_label' ], 10, 3 );
	}

	/**
	 * Append a WPForms group to the plugins list used by the list table.
	 *
	 * @since 1.10.0.5
	 *
	 * @param array|mixed $plugins Plugins grouped by status (`all`, `active`, ...).
	 *
	 * @return array
	 */
	public function add_category( $plugins ): array {

		$plugins = (array) $plugins;

		if ( empty( $plugins['all'] ) || ! is_array( $plugins['all'] ) ) {
			return $plugins;
		}

		$wpforms_plugins = [];

		foreach ( $plugins['all'] as $file => $plugin_data ) {
			if ( ! is_array( $plugin_data ) ) {
				continue;
			}

			if ( $this->is_wpforms_plugin( (string) $file, $plugin_data ) ) {
				$wpforms_plugins[ $file ] = $plugin_data;
			}
		}

		if ( ! empty( $wpforms_plugins ) ) {
			$plugins[ self::STATUS_KEY ] = $wpforms_plugins;
		}

		return $plugins;
	}

	/**
	 * Provide the human-readable label for the WPForms category tab.
	 *
	 * The list table escapes the returned string and appends the count
	 * span, so the value must be plain text without HTML.
	 *
	 * @since 1.10.0.5
	 *
	 * @param string|mixed $text  Status text. Default empty string.
	 * @param int|mixed    $count Number of plugins in the category.
	 * @param string|mixed $type  The status slug being filtered.
	 *
	 * @return string
	 * @noinspection PhpUnusedParameterInspection
	 */
	public function category_label( $text, $count, $type ): string { // phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.FoundAfterLastUsed

		if ( $type !== self::STATUS_KEY ) {
			return is_string( $text ) ? $text : '';
		}

		// "WPForms" is a brand name, but keep the call translatable so locales
		// can adjust casing if needed. The %s count is appended by core.
		return __( 'WPForms', 'wpforms-lite' );
	}

	/**
	 * Determine whether a plugin should be listed under the WPForms category.
	 *
	 * The default rule matches by folder slug: the main plugin (`wpforms`)
	 * and any `wpforms-*` addon. Third parties can override via the
	 * exposed filter without touching this class.
	 *
	 * @since 1.10.0.5
	 *
	 * @param string $file        Plugin file path (e.g. `wpforms-stripe/wpforms-stripe.php`).
	 * @param array  $plugin_data Plugin metadata as returned by `get_plugins()`.
	 *
	 * @return bool
	 */
	private function is_wpforms_plugin( string $file, array $plugin_data ): bool {

		$slug    = explode( '/', $file )[0];
		$is_ours = $slug === self::SLUG_PREFIX || strpos( $slug, self::SLUG_PREFIX . '-' ) === 0;

		/**
		 * Filters whether a plugin should be listed under the WPForms category tab.
		 *
		 * @since 1.10.0.5
		 *
		 * @param bool   $is_ours     Whether the plugin is recognised as a WPForms plugin.
		 * @param string $file        Plugin file path (e.g. `wpforms-stripe/wpforms-stripe.php`).
		 * @param array  $plugin_data Plugin metadata as returned by `get_plugins()`.
		 *
		 * @return bool Whether the plugin should appear under the WPForms tab.
		 */
		return (bool) apply_filters( 'wpforms_admin_plugins_category_is_wpforms_plugin', $is_ours, $file, $plugin_data ); // phpcs:ignore WPForms.PHP.ValidateHooks.InvalidHookName
	}
}