we_devs_settings_api = new \WeDevs_Settings_API;
$settings = Settings::get_instance();
$this->version = $settings->getVersion();
$this->prefix = $settings->getPrefix();
add_action( 'admin_init', array($this, 'admin_init') );
add_action( 'admin_init', array($this, 'checkInstagramQueryURL') );
add_action( 'admin_menu', array($this, 'admin_menu') );
add_action( 'admin_enqueue_scripts', array( $this, 'enqueueAdminAssets' ) );
}
/**
* Enqueue Admin Page js and css
*/
public function enqueueAdminAssets() {
//CSS
wp_enqueue_style(
"{$this->prefix}-admin-page",
stratum_get_plugin_url( 'assets/css/admin-page.min.css' ),
[],
$this->version
);
wp_enqueue_style(
"{$this->prefix}-icons-style",
stratum_get_plugin_url( './assets/css/stratum.min.css' ),
apply_filters(
'stratum/editor_css/dependencies',
[]
),
$this->version
);
}
public function admin_init() {
//Fill settings
$this->we_devs_settings_api->set_sections( $this->get_settings_sections() );
$this->we_devs_settings_api->set_fields( $this->get_settings_fields() );
//Init settings
$this->we_devs_settings_api->admin_init();
}
public function stratum_instagram_notice_success() {
?>
true,
),
admin_url( 'admin.php?page=stratum-settings#stratum_api' )
)
); //Redirect
}
if (isset($_GET['stratum-instagram-success'])) {
add_action( 'admin_notices', [$this, 'stratum_instagram_notice_success'] );
}
if (isset($_GET['stratum-instagram-error'])) {
add_action( 'admin_notices', [$this, 'stratum_instagram_notice_error'] );
}
}
public function admin_menu() {
add_menu_page(
esc_html__( 'Stratum', 'stratum' ),
esc_html__( 'Stratum', 'stratum' ),
'manage_options',
'stratum',
array($this, 'about_page'),
'data:image/svg+xml;base64,' . base64_encode(
''
),
90
);
add_submenu_page(
'stratum',
esc_html__( 'Stratum Settings', 'stratum' ),
esc_html__( 'Settings', 'stratum' ),
'manage_options',
'stratum-settings',
array( $this, 'plugin_page' )
);
}
public function about_page(){
$settings = \Stratum\Settings::get_instance();
$pluginData = $settings->getPluginData();
$storeUrl = isset( $pluginData['PluginURI'] ) ? $pluginData['PluginURI'] : 'https://motopress.com/';
?>
version); ?>
= 1.4.0, Mar 25 2024 =
- Added Instagram Access Token encryption.
- Minor bugfixes and improvements.
= 1.3.16, Feb 13 2024 =
- Minor bugfixes and improvements.
= 1.3.15, May 24 2023 =
- Improved compatibility with latest Elementor versions.
- Minor bugfixes and improvements.
= 1.3.14, Mar 10 2023 =
- Fixed miscellaneous Elementor deprecations.
= 1.3.13, Mar 23 2022 =
- Fixed an issue with missing descriptions in the Vertical Timeline widget.
- Fixed an issue with multiple markers in the Advanced Google Maps widget.
- Fixed an issue when the Swiper slider may not have been initialized with the "Improved Asset Loading" Elementor option enabled.
- Fixed an issue with the currency alignment in the Price Table widget.
- Minor bugfixes and improvements.
= 1.3.12, Nov 30 2021 =
- Fixed an issue with Advanced Slider on mobile devices.
= 1.3.11, Oct 27 2021 =
- Security - sanitization and escaping.
= 1.3.10, Aug 17 2021 =
- Fixed an issue with links in Horizontal Timeline and Accordion widgets.
= 1.3.9, Jul 21 2021 =
- Minor bugfixes and improvements.
= 1.3.8, May 5 2021 =
- Minor bugfixes and improvements.
= 1.3.7, Apr 1 2021 =
- Added Table widget.
- Added Content Switcher widget.
- Added the ability to automatically refresh Instagram access token.
- Minor bugfixes and improvements.
= 1.3.6, Feb 17 2021 =
- Minor bugfixes and improvements.
= 1.3.5, Dec 23 2020 =
- Improved compatibility with WordPress 5.6 and Elementor Pro.
- Minor bugfixes and improvements.
= 1.3.4, Sep 8 2020 =
- Minor bugfixes and improvements.
= 1.3.3, Aug 28 2020 =
- Added Vertical Timeline widget.
- Added Horizontal Timeline widget.
- Added Lottie Animations widget.
- Added Countdown widget.
= 1.3.2, Aug 12 2020 =
- Improved compatibility with WordPress 5.5.
= 1.3.1, Jul 31 2020 =
- Fixed an issue with Instagram widget.
= 1.3.0, Jun 10 2020 =
- Added Advanced Accordion widget.
- Added Advanced Tabs widget.
- Added Image Accordion widget.
- Improved the plugin color palette.
- Added the Templates Library control.
- Fixed an issue with "Instagram getToken" in the Instagram widget.
- Fixed an issue with controls in the Advanced Google Maps widget.
- Minor bugfixes and improvements.
= 1.2.0, Apr 29 2020 =
- Added Advanced Google Map widget.
- Added Advanced Posts widget.
- Added Advanced Slider widget.
- Added Testimonial Carousel widget.
- Added Flip Box widget.
- Minor bugfixes and improvements.
= 1.1.0, Mar 30 2020 =
- Added Image Hotspot widget.
- Added Masonry Gallery widget.
- Added Circular Progress Bar widget.
- Minor bugfixes and improvements.
= 1.0.0, Mar 6 2020 =
'stratum_widgets',
'title' => esc_html__( 'Elements', 'stratum' ),
'addons' => true,
'icon' => 'dashicons dashicons-admin-tools',
),
array(
'id' => 'stratum_style',
'title' => esc_html__( 'Style', 'stratum' ),
'icon' => 'dashicons dashicons-admin-site-alt3',
),
array(
'id' => 'stratum_api',
'title' => esc_html__( 'API', 'stratum' ),
'icon' => 'dashicons dashicons-admin-network',
),
) );
return $sections;
}
/**
* Returns all the settings fields
*
* @return array settings fields
*/
public function get_settings_fields() {
$encryption = new String_Encryption();
$stratum_api = get_option( 'stratum_api', [] );
$instagram_access_token = isset( $stratum_api['instagram_access_token'] ) ? $encryption->decrypt( $stratum_api['instagram_access_token'] ) : '';
$settings_fields = apply_filters( 'stratum_settings_fields', array(
'stratum_widgets' => apply_filters( 'stratum_required_widgets', array(
array(
'name' => 'instagram',
'label' => esc_html__( 'Instagram', 'stratum' ),
'desc' => esc_html__( 'Real-life Instagram feed in your WordPress.', 'stratum' ),
'icon' => 'stratum-icon-instagram',
'type' => 'toggle',
'default' => 'on'
),
array(
'name' => 'banner',
'label' => esc_html__( 'Banner', 'stratum' ),
'desc' => esc_html__( 'Creative animated banners for promos and announcements.', 'stratum' ),
'icon' => 'stratum-icon-banner',
'type' => 'toggle',
'default' => 'on'
),
array(
'name' => 'counter',
'label' => esc_html__( 'Counter', 'stratum' ),
'desc' => esc_html__( 'Animated counters to visualize data.', 'stratum' ),
'icon' => 'stratum-icon-counter',
'type' => 'toggle',
'default' => 'on'
),
array(
'name' => 'price-menu',
'label' => esc_html__( 'Price Menu', 'stratum' ),
'desc' => esc_html__( 'Food menus or other listings with prices.', 'stratum' ),
'icon' => 'stratum-icon-price-menu',
'type' => 'toggle',
'default' => 'on'
),
array(
'name' => 'price-list',
'label' => esc_html__( 'Price List', 'stratum' ),
'desc' => esc_html__( 'Price variables or categorized lists of individual menu items.', 'stratum' ),
'icon' => 'stratum-icon-price-list',
'type' => 'toggle',
'default' => 'on'
),
array(
'name' => 'price-table',
'label' => esc_html__( 'Price Table', 'stratum' ),
'desc' => esc_html__( 'Pricing and comparison tables.', 'stratum' ),
'icon' => 'stratum-icon-price-table',
'type' => 'toggle',
'default' => 'on'
),
array(
'name' => 'table',
'label' => esc_html__( 'Table', 'stratum' ),
'desc' => esc_html__( 'Build responsive tables and customize their content and styling.', 'stratum' ),
'icon' => 'eicon-table',
'type' => 'toggle',
'default' => 'on'
),
array(
'name' => 'content-switcher',
'label' => esc_html__( 'Content Switcher', 'stratum' ),
'desc' => esc_html__( 'Add a toggle or structure your content into switchable tabs - perfect for pricing plans and data organization.', 'stratum' ),
'icon' => 'eicon-dual-button',
'type' => 'toggle',
'default' => 'on'
),
array(
'name' => 'image-hotspot',
'label' => esc_html__( 'Image Hotspot', 'stratum' ),
'desc' => esc_html__( 'Animated pointers with tooltips to place over images.', 'stratum' ),
'icon' => 'stratum-icon-image-hotspot',
'type' => 'toggle',
'default' => 'on'
),
array(
'name' => 'circle-progress-bar',
'label' => esc_html__( 'Circle Progress Bar', 'stratum' ),
'desc' => esc_html__( 'A circle-shaped bar with an animated activity progress indicator.', 'stratum' ),
'icon' => 'stratum-icon-circle-progress-bar',
'type' => 'toggle',
'default' => 'on'
),
array(
'name' => 'masonry-gallery',
'label' => esc_html__( 'Masonry Gallery', 'stratum' ),
'desc' => esc_html__( 'A masonry-styled responsive image gallery.', 'stratum' ),
'icon' => 'stratum-icon-masonry-gallery',
'type' => 'toggle',
'default' => 'on'
),
array(
'name' => 'advanced-slider',
'label' => esc_html__( 'Advanced Slider', 'stratum' ),
'desc' => esc_html__( 'A fully customizable slider, including the number of columns, horizontal and vertical scrolling, navigation, etc.', 'stratum' ),
'icon' => 'stratum-icon-advanced-slider',
'type' => 'toggle',
'default' => 'on'
),
array(
'name' => 'advanced-posts',
'label' => esc_html__( 'Advanced Posts', 'stratum' ),
'desc' => esc_html__( 'Showcase your automatically sourced posts and pages in different grid or list layouts.', 'stratum' ),
'icon' => 'stratum-icon-advanced-posts',
'type' => 'toggle',
'default' => 'on'
),
array(
'name' => 'advanced-accordion',
'label' => esc_html__( 'Advanced Accordion', 'stratum' ),
'desc' => esc_html__( 'Horizontal accordion tabs with support for custom Library templates.', 'stratum' ),
'icon' => 'stratum-icon-advanced-accordion',
'type' => 'toggle',
'default' => 'on'
),
array(
'name' => 'advanced-tabs',
'label' => esc_html__( 'Advanced Tabs', 'stratum' ),
'desc' => esc_html__( 'Fully customizable horizontal or vertical-oriented tabs with support for custom Library templates.', 'stratum' ),
'icon' => 'stratum-icon-advanced-tabs',
'type' => 'toggle',
'default' => 'on'
),
array(
'name' => 'countdown',
'label' => esc_html__( 'Countdown', 'stratum' ),
'desc' => esc_html__( 'Dynamic countdown timer with deeply customizable numeric values and time labels.', 'stratum' ),
'icon' => 'stratum-icon-countdown',
'type' => 'toggle',
'default' => 'on'
),
[
'name' => 'testimonial-carousel',
'label' => esc_html__( 'Testimonial Carousel', 'stratum' ),
'desc' => esc_html__( 'A ready-made template for admin-added testimonials.', 'stratum' ),
'icon' => 'stratum-icon-testimonial-carousel',
'type' => 'toggle',
'default' => 'on'
],
[
'name' => 'advanced-google-map',
'label' => esc_html__( 'Advanced Google Map', 'stratum' ),
'desc' => esc_html__( 'Google Maps with customizable location markets and map styles.', 'stratum' ),
'icon' => 'stratum-icon-advanced-google-map',
'type' => 'toggle',
'default' => 'on'
],
[
'name' => 'flip-box',
'label' => esc_html__( 'Flip Box', 'stratum' ),
'desc' => esc_html__( 'Flip Box with animation that is triggered on hover and fully customizable front & back sections.', 'stratum' ),
'icon' => 'stratum-icon-flip-box',
'type' => 'toggle',
'default' => 'on'
],
[
'name' => 'image-accordion',
'label' => esc_html__( 'Image Accordion', 'stratum' ),
'desc' => esc_html__( 'Highlight your images with amazing hover and click effects using Image Accordion', 'stratum' ),
'icon' => 'stratum-icon-image-accordion',
'type' => 'toggle',
'default' => 'on'
],
[
'name' => 'vertical-timeline',
'label' => esc_html__( 'Vertical Timeline', 'stratum' ),
'desc' => esc_html__( 'Display events on your pages using Vertical Timeline widget, that allows adding content, including icons, imagery, and descriptions', 'stratum' ),
'icon' => 'stratum-icon-vertical-timeline',
'type' => 'toggle',
'default' => 'on'
],
[
'name' => 'horizontal-timeline',
'label' => esc_html__( 'Horizontal Timeline', 'stratum' ),
'desc' => esc_html__( 'Let the visitors know about the events and projects on your website using the Horizontal Timeline widget', 'stratum' ),
'icon' => 'stratum-icon-horizontal-timeline',
'type' => 'toggle',
'default' => 'on'
],
[
'name' => 'lottie-animations',
'label' => esc_html__( 'Lottie Animations', 'stratum' ),
'desc' => esc_html__( 'Lottie Animations widget give you the ability to easily add Lottie Animations to your Elementor pages with no need to add custom code', 'stratum' ),
'icon' => 'stratum-icon-lottie-animations',
'type' => 'toggle',
'default' => 'on'
]
) ),
'stratum_style' => array(
array(
'name' => 'primary_color',
'label' => esc_html__( 'Primary color', 'stratum' ),
'desc' => esc_html__( 'Select your primary color. Default: #3878ff', 'stratum' ),
'type' => 'color',
'default' => '#3878ff'
),
array(
'name' => 'secondary_color',
'label' => esc_html__( 'Secondary color (Hover)', 'stratum' ),
'desc' => esc_html__( 'Select your secondary color. Default: #565656', 'stratum' ),
'type' => 'color',
'default' => '#565656'
),
array(
'name' => 'background_color',
'label' => esc_html__( 'Background color', 'stratum' ),
'desc' => esc_html__( 'Select your secondary color. Default: #71d7f7', 'stratum' ),
'type' => 'color',
'default' => '#71d7f7'
),
array(
'name' => 'background_color_active',
'label' => esc_html__( 'Background color (Active)', 'stratum' ),
'desc' => esc_html__( 'Select your secondary color. Default: #0097c6', 'stratum' ),
'type' => 'color',
'default' => '#0097c6'
),
array(
'name' => 'background_color_hover',
'label' => esc_html__( 'Background color (Hover)', 'stratum' ),
'desc' => esc_html__( 'Select your secondary color. Default: #008fbc', 'stratum' ),
'type' => 'color',
'default' => '#008fbc'
),
),
'stratum_api' => [
'instagram_access_token' => [
'name' => 'instagram_access_token',
'label' => esc_html__( 'Instagram Access Token', 'stratum' ),
'desc_btn' => esc_html__( 'Connect Instagram Account', 'stratum' ),
'desc_class' => 'large',
'desc_link' => esc_url(
'https://api.instagram.com/oauth/authorize?client_id=910186402812397&redirect_uri=' .
'https://api.getmotopress.com/get_instagram_token.php&scope=user_profile,user_media&response_type=code&state=' .
admin_url( 'admin.php' )
),
'type' => 'text',
'is_encrypted' => true,
],
'google_api_key' => [
'name' => 'google_api_key',
'label' => esc_html__( 'Google Maps API Key', 'stratum' ),
'desc' => sprintf( '%s', esc_html__( 'Get the API key', 'stratum' ) ),
'type' => 'text'
]
]
) );
if ( ! empty( $instagram_access_token ) ) {
$settings_fields['stratum_api']['instagram_access_token']['desc_extra_btn'] = esc_html__( 'Refresh Access Token', 'stratum' );
$settings_fields['stratum_api']['instagram_access_token']['desc_extra_class'] = 'large';
$settings_fields['stratum_api']['instagram_access_token']['desc_extra_link'] = esc_url(
'https://api.getmotopress.com/refresh_instagram_token.php?access_token='.$instagram_access_token.'&state=' .
admin_url( 'admin.php?page=stratum-settings#stratum_api' )
);
try {
$profile_data_json = wp_remote_get(
'https://graph.instagram.com/me?fields=username&access_token=' . $instagram_access_token
);
if ( ( ! is_wp_error( $profile_data_json ) ) && ( 200 === wp_remote_retrieve_response_code( $profile_data_json ) ) ) {
$profile_data = json_decode( $profile_data_json['body'] );
if ( json_last_error() === JSON_ERROR_NONE ) {
$profile_display_val = '';
if ( isset( $profile_data->username ) ) {
$profile_display_val = $profile_data->username;
} elseif ( isset( $profile_data->id ) ) {
$profile_display_val = $profile_data->id;
}
$settings_fields['stratum_api']['instagram_access_token']['desc'] =
! empty( $profile_display_val )
? sprintf(
//translators: %s is username or user id
esc_html__('Account: %s', 'stratum'),
esc_html( $profile_data->username )
)
: '';
}
}
} catch ( \Exception $profile_data_exception ) {
$settings_fields['stratum_api']['instagram_access_token']['desc'] = esc_html( $profile_data_exception->getMessage() );
}
stratum()->get_token_manager()->schedule_token_refresh_event();
}
return $settings_fields;
}
public function plugin_page() {
if ( isset( $_GET['settings-updated'] ) ) {
printf( '', esc_html__( 'Plugin settings updated successfully', 'stratum' ) );
}
$count = count( $this->get_settings_sections() );
if ( $count <= 1 ) {
$class = 'stratum-settings-sections-no';
} else {
$class = 'stratum-settings-sections-yes';
}
echo '';
$this->we_devs_settings_api->show_navigation();
$this->we_devs_settings_api->show_forms();
echo '
';
}
}