# master-addons/3.1.2/inc/admin/templates/includes/classes/api.php

Master Addons for Elementor – Elementor Addons, Widgets, Mega Menu Builder, Popup Builder, Widget Builder &amp; Template Kits, version 3.1.2. 114 lines.

- Page: https://pluginprobe.com/plugins/master-addons/3.1.2/code/inc/admin/templates/includes/classes/api.php
- Raw: https://pluginprobe.com/plugins/master-addons/3.1.2/raw/inc/admin/templates/includes/classes/api.php
- Modified: 2026-03-08T11:32:50+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/master-addons/3.1.2/code/inc/admin/templates/includes/classes/api.php#L10-L20`.

```php
<?php
	/**
	 * Author Name: Liton Arefin
	 * Author URL: https://jeweltheme.com
	 * Date: 9/8/19
	 */


	namespace MasterAddons\Inc\Admin\Templates\Includes\Classes;

	use MasterAddons\Inc\Admin\Templates;

	if( ! defined( 'ABSPATH' ) ) exit; // No access of directly access

	if ( ! class_exists( 'API' ) ) {

		class API {

			private $config     = array();

			private $enabled    = null;

			public function __construct() {
				$this->config  = Templates\master_addons_templates()->config->get( 'api' );
			}


			public function is_enabled() {

				if ( null !== $this->enabled ) {
					return $this->enabled;
				}

				if ( empty( $this->config['enabled'] ) || true !== $this->config['enabled'] ) {
					$this->enabled = false;
					return $this->enabled;
				}

				if ( empty( $this->config['base'] ) || empty( $this->config['path'] ) || empty( $this->config['endpoints'] ) ) {
					$this->enabled = false;
					return $this->enabled;
				}

				$this->enabled = true;

				return $this->enabled;
			}

			public function api_url( $flag ) {

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

				if ( empty( $this->config['endpoints'][ $flag ] ) ) {
					return false;
				}

				return $this->config['base'] . $this->config['path'] . $this->config['endpoints'][ $flag ];
			}


			public function get_info( $key = '' ) {

				$api_url = $this->api_url( 'info' );

				if ( ! $api_url ) {
					return false;
				}

				$response = wp_remote_get( $api_url, $this->request_args() );

				$body = wp_remote_retrieve_body( $response );
				$body = json_decode( $body, true );

				if ( ! $body || ! isset( $body['success'] ) || true !== $body['success'] ) {
					return false;
				}

				if ( ! $key ) {
					unset( $body['success'] );
					return $body;
				}

				if ( is_string( $key ) ) {
					return isset( $body[ $key ] ) ? $body[ $key ] : false;
				}

				if ( is_array( $key ) ) {

					$result = array();

					foreach ( $key as $_key ) {
						$result[ $_key ] = isset( $body[ $_key ] ) ? $body[ $_key ] : false;
					}

					return $result;

				}

			}


			public function request_args() {
				return array(
					'timeout'   => 60,
					'sslverify' => false
				);
			}

		}

	}

```
