PluginProbe
Sharing Image / 3.2
Sharing Image v3.2
3.10 trunk 2.0 2.0.0 2.0.1 2.0.10 2.0.11 2.0.12 2.0.13 2.0.14 2.0.15 2.0.16 2.0.17 2.0.2 2.0.3 2.0.4 2.0.5 2.0.6 2.0.7 2.0.8 2.0.9 3.0 3.1 3.2 3.3 All 29 releases
sharing-image / classes / class-snippets.php

class-snippets.php in Sharing Image 3.2, at classes/class-snippets.php

91 lines 2.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Handle 3rd party plugin snippets.
4 *
5 * @package sharing-image
6 * @author Anton Lukin
7 */
8
9 namespace Sharing_Image;
10
11 if ( ! defined( 'ABSPATH' ) ) {
12 die;
13 }
14
15 /**
16 * Snippets class.
17 *
18 * @class Snippets
19 */
20 class Snippets {
21 /**
22 * Store list of plugin snippets.
23 *
24 * @var array
25 */
26 private static $snippets = array();
27
28 /**
29 * Init class actions and filters.
30 */
31 public static function init() {
32 add_action( 'init', array( __CLASS__, 'init_snippets' ) );
33 }
34
35 /**
36 * Init plugin snippets.
37 */
38 public static function init_snippets() {
39 $list = array(
40 'Sharing_Image\Snippets\YoastSeo' => SHARING_IMAGE_DIR . 'snippets/class-yoastseo.php',
41 'Sharing_Image\Snippets\RankMath' => SHARING_IMAGE_DIR . 'snippets/class-rankmath.php',
42 'Sharing_Image\Snippets\TheSEOFramework' => SHARING_IMAGE_DIR . 'snippets/class-theseoframework.php',
43 'Sharing_Image\Snippets\Squirrly' => SHARING_IMAGE_DIR . 'snippets/class-squirrly.php',
44 'Sharing_Image\Snippets\SEOPress' => SHARING_IMAGE_DIR . 'snippets/class-seopress.php',
45 'Sharing_Image\Snippets\SlimSEO' => SHARING_IMAGE_DIR . 'snippets/class-slimseo.php',
46 'Sharing_Image\Snippets\AIOSEO' => SHARING_IMAGE_DIR . 'snippets/class-aioseo.php',
47 );
48
49 /**
50 * Filter 3rd party plugin snippets list.
51 *
52 * @param array $snippets A key-value array with class name key and path to the file as value.
53 */
54 $list = apply_filters( 'sharing_image_snippets', $list );
55
56 foreach ( $list as $plugin_class => $path ) {
57 include_once $path;
58
59 if ( ! class_exists( $plugin_class ) ) {
60 continue;
61 }
62
63 if ( ! $plugin_class::is_activated() ) {
64 continue;
65 }
66
67 if ( Config::is_active_snippets() ) {
68 $plugin_class::init_filters();
69 }
70
71 self::$snippets[] = $plugin_class::get_name();
72 }
73 }
74
75 /**
76 * Get list of snippets plugins names and links.
77 *
78 * @return array List of snippets.
79 */
80 public static function get_snippets() {
81 /**
82 * Filters list of plugin snippets names.
83 *
84 * @since 3.0
85 *
86 * @param array $names List of snippets names.
87 */
88 return apply_filters( 'sharing_image_get_snippets', self::$snippets );
89 }
90 }
91