PluginProbe
WPGet API – Connect to any external REST API / 1.5.0
WPGet API – Connect to any external REST API v1.5.0
1.9.2 1.9.3 1.9.4 1.9.5 1.9.6 1.9.7 1.9.8 1.9.9 2.0.0 2.0.1 2.0.2 2.0.3 2.0.4 2.0.5 2.0.6 2.1.0 2.1.1 2.1.3 2.1.4 2.1.5 2.2.0 2.2.1 2.2.10 2.2.2 2.2.3 All 97 releases
wpgetapi / wpgetapi.php

wpgetapi.php in WPGet API – Connect to any external REST API 1.5.0, at wpgetapi.php

177 lines 4.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Plugin Name: WPGetAPI
4 * Plugin URI: https://wordpress.org/plugins/wpgetapi/
5 * Description: Connect to external API's and display the API data.
6 * Author: WPGetAPI
7 * Author URI: https://wpgetapi.com/
8 * Version: 1.5.0
9 * Text Domain: wpgetapi
10 * Domain Path: /languages/
11 * License: GPL2 or later
12 *
13 */
14
15 // Exit if accessed directly.
16 if ( ! defined( 'ABSPATH' ) ) exit;
17
18 /**
19 * Main Class.
20 *
21 * @since 1.0.0
22 */
23 final class WpGetApi {
24
25 /**
26 * @var The one true instance
27 * @since 1.0.0
28 */
29 protected static $_instance = null;
30
31 public $version = '1.5.0';
32
33 /**
34 * Main Instance.
35 */
36 public static function instance() {
37 if ( is_null( self::$_instance ) ) {
38 self::$_instance = new self();
39 }
40 return self::$_instance;
41 }
42
43 /**
44 * Throw error on object clone.
45 *
46 * @since 1.0.0
47 * @access protected
48 * @return void
49 */
50 public function __clone() {
51 _doing_it_wrong( __FUNCTION__, __( 'Cheatin&#8217; huh?', 'wpgetapi' ), '1.0.0' );
52 }
53
54 /**
55 * Disable unserializing of the class.
56 * @since 1.0.0
57 */
58 public function __wakeup() {
59 _doing_it_wrong( __FUNCTION__, __( 'Cheatin&#8217; huh?', 'wpgetapi' ), '1.0.0' );
60 }
61
62 /**
63 *
64 * @since 1.0.0
65 */
66 public function __construct() {
67 $this->define_constants();
68 $this->hooks();
69 $this->includes();
70
71 do_action( 'wpgetapi_loaded' );
72 }
73
74 /**
75 * Define Constants.
76 * @since 1.0.0
77 */
78 private function define_constants() {
79 $this->define( 'WPGETAPIDIR',plugin_dir_path( __FILE__ ) );
80 $this->define( 'WPGETAPIURL',plugin_dir_url( __FILE__ ) );
81 $this->define( 'WPGETAPIBASENAME', plugin_basename( __FILE__ ) );
82 $this->define( 'WPGETAPIVERSION', $this->version );
83 }
84
85 /**
86 * Define hooks.
87 * @since 1.4.2
88 */
89 private function hooks() {
90 $plugin_file = WPGETAPIBASENAME;
91 add_filter( "plugin_action_links_{$plugin_file}", array( $this, 'plugin_action_links' ), 10, 4 );
92 add_filter( 'plugin_row_meta', array( $this, 'filter_plugin_row_meta' ), 10, 4 );
93 }
94
95 /**
96 * Define constant if not already set.
97 * @since 1.0.0
98 */
99 private function define( $name, $value ) {
100 if ( ! defined( $name ) ) {
101 define( $name, $value );
102 }
103 }
104
105
106 /**
107 * Include required files.
108 * @since 1.0.0
109 */
110 public function includes() {
111
112 require_once ( WPGETAPIDIR . '/lib/cmb2/init.php' );
113
114 include_once ( WPGETAPIDIR . 'includes/class-encryption.php' );
115 include_once ( WPGETAPIDIR . 'includes/class-admin-options.php' );
116
117 include_once ( WPGETAPIDIR . 'includes/functions.php' );
118 include_once ( WPGETAPIDIR . 'includes/class-enqueues.php' );
119 include_once ( WPGETAPIDIR . 'includes/class-api.php' );
120
121 include_once ( WPGETAPIDIR . 'frontend/functions.php' );
122
123 }
124
125 /**
126 * Filters the array of row meta for each plugin in the Plugins list table.
127 *
128 * @param array<int,string> $plugin_meta An array of the plugin row's meta data.
129 * @param string $plugin_file Path to the plugin file relative to the plugins directory.
130 * @return array<int,string> An array of the plugin row's meta data.
131 */
132 function filter_plugin_row_meta( array $plugin_meta, $plugin_file ) {
133 if ( 'wpgetapi/wpgetapi.php' !== $plugin_file ) {
134 return $plugin_meta;
135 }
136
137 $plugin_meta[] = sprintf(
138 '<a href="%1$s">%2$s</a>',
139 'https://wpgetapi.com/docs/?utm_campaign=Docs&utm_medium=plugin&utm_source=external',
140 esc_html( 'Docs', 'wpgetapi' )
141 );
142
143 return $plugin_meta;
144 }
145
146
147 /**
148 * Adds items to the plugin's action links on the Plugins listing screen.
149 *
150 * @param array<string,string> $actions Array of action links.
151 * @param string $plugin_file Path to the plugin file relative to the plugins directory.
152 * @param mixed[] $plugin_data An array of plugin data.
153 * @param string $context The plugin context.
154 * @return array<string,string> Array of action links.
155 */
156 function plugin_action_links( $actions, $plugin_file, $plugin_data, $context ) {
157 $new = array(
158 'setup' => sprintf(
159 '<a href="%s">%s</a>',
160 esc_url( admin_url( 'admin.php?page=wpgetapi_setup' ) ),
161 esc_html__( 'API Setup', 'wpgetapi' )
162 ),
163 );
164
165 return array_merge( $new, $actions );
166 }
167
168 }
169
170
171 /**
172 * Run the plugin.
173 */
174 function WpGetApi() {
175 return WpGetApi::instance();
176 }
177 WpGetApi();