Skip to content

Commit 7174140

Browse files
committed
Added ALNP Pro Preview
1 parent 7bf0caa commit 7174140

File tree

4 files changed

+157
-12
lines changed

4 files changed

+157
-12
lines changed

assets/js/admin/pro-preview.js

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
/* global alnp_pro_preview_params */
2+
( function( $, params ) {
3+
4+
$('.nav-tab-wrapper a').on('click', function(e) {
5+
var href = $(this).attr('href'),
6+
tab = $(this).data('tab'),
7+
jc;
8+
9+
if ( href == '#' ) {
10+
e.preventDefault();
11+
12+
jc = $.dialog({
13+
icon: 'dashicons dashicons-info',
14+
title: params.i18n_coming_soon,
15+
content: '<p>' + params.i18n_coming_soon_content + '</p>',
16+
rtl: params.is_rtl,
17+
type: 'blue',
18+
draggable: false,
19+
boxWidth: '500px',
20+
useBootstrap: false,
21+
});
22+
23+
if ( tab == 'comments' ) {
24+
setTimeout(function () {
25+
jc.setContentAppend( '<p>' + params.i18n_comments_content + '</p>' );
26+
}, 100);
27+
}
28+
29+
if ( tab == 'load-and-scroll' ) {
30+
setTimeout(function () {
31+
jc.setContentAppend( '<p>' + params.i18n_load_scroll_content + '</p>' );
32+
}, 100);
33+
}
34+
35+
if ( tab == 'restrictions' ) {
36+
setTimeout(function () {
37+
jc.setContentAppend( '<p>' + params.i18n_restrictions_content + '</p>' );
38+
}, 100);
39+
}
40+
41+
if ( tab == 'query' ) {
42+
setTimeout(function () {
43+
jc.setContentAppend( '<p>' + params.i18n_query_content + '</p>' );
44+
}, 100);
45+
}
46+
47+
if ( tab == 'license' ) {
48+
setTimeout(function () {
49+
jc.setContentAppend( '<p>' + params.i18n_license_content + '</p>' );
50+
}, 100);
51+
}
52+
}
53+
});
54+
55+
})( jQuery, alnp_pro_preview_params );

includes/admin/class-alnp-admin-assets.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,8 +118,14 @@ public function admin_scripts() {
118118

119119
// Variables for Pro Preview JavaScript.
120120
wp_localize_script( AUTO_LOAD_NEXT_POST_SLUG . '_pro_preview', 'alnp_pro_preview_params', array(
121-
'is_rtl' => is_rtl() ? true : false,
122-
'i18n_coming_soon' => esc_html__( 'Coming Soon', 'auto-load-next-post' ),
121+
'is_rtl' => is_rtl() ? true : false,
122+
'i18n_coming_soon' => esc_html__( 'Coming Soon', 'auto-load-next-post' ),
123+
'i18n_coming_soon_content' => sprintf( esc_html__( '%1$s%3$s%2$s coming soon with more features. Sign up in the sidebar to be notified!', 'auto-load-next-post' ), '<strong>', '</strong>', esc_html__( 'Auto Load Next Post Pro', 'auto-load-next-post' ) ),
124+
'i18n_comments_content' => sprintf( esc_html__( '%1$sComments:%2$s More control on how comments should interact when each post loads.', 'auto-load-next-post' ), '<strong>', '</strong>' ),
125+
'i18n_load_scroll_content' => sprintf( esc_html__( '%1$sLoad and Scroll:%2$s Choose what loads next, enable to load split posts, scroll transistion and scroll speed.', 'auto-load-next-post' ), '<strong>', '</strong>' ),
126+
'i18n_restrictions_content' => sprintf( esc_html__( '%1$sRestrictions:%2$s Manage which post types Auto Load Next Post should load on, how many posts to load per session and which user roles and users are excluded from loading posts.', 'auto-load-next-post' ), '<strong>', '</strong>' ),
127+
'i18n_query_content' => sprintf( esc_html__( '%1$sQuery:%2$s Customise the query of posts before Auto Load Next Post loads them including excluded posts and post formats.', 'auto-load-next-post' ), '<strong>', '</strong>' ),
128+
'i18n_license_content' => esc_html__( 'License is managed here for support and remote plugin updates.', 'auto-load-next-post' )
123129
) );
124130

125131
// Load plugin settings.
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
<?php
2+
/**
3+
* Auto Load Next Post Pro Preview class
4+
*
5+
* Adds a preview of the options coming to the Pro release.
6+
*
7+
* @since 1.6.0
8+
* @author Sébastien Dumont
9+
* @category Classes
10+
* @package Auto Load Next Post/Classes/Pro Preview
11+
* @license GPL-2.0+
12+
*/
13+
14+
// Exit if accessed directly.
15+
if ( ! defined( 'ABSPATH' ) ) {
16+
exit;
17+
}
18+
19+
if ( ! class_exists( 'ALNP_Pro_Preview' ) ) {
20+
21+
class ALNP_Pro_Preview {
22+
23+
/**
24+
* Initialize.
25+
*
26+
* @access public
27+
*/
28+
public function __construct() {
29+
add_filter( 'alnp_settings_tabs_array', array( $this, 'add_pro_tabs' ), 99 );
30+
add_filter( 'alnp_settings_tab_url', array( $this, 'hash'), 0, 2 );
31+
} // END __construct()
32+
33+
/**
34+
* Adds the settings tabs that will be available in Pro.
35+
*
36+
* @access public
37+
* @param array $pages
38+
* @return array $pages
39+
*/
40+
public function add_pro_tabs( $pages ) {
41+
$pro_pages = array(
42+
'comments' => __( 'Comments', 'auto-load-next-post' ),
43+
'load-and-scroll' => __( 'Load & Scroll', 'auto-load-next-post' ),
44+
'restrictions' => __( 'Restrictions', 'auto-load-next-post' ),
45+
'query' => __( 'Query', 'auto-load-next-post' ),
46+
'license' => __( 'License', 'auto-load-next-post' ),
47+
);
48+
49+
$pages = array_merge( $pages, $pro_pages );
50+
51+
return $pages;
52+
} // END add_pro_tabs()
53+
54+
/**
55+
* Overrides the link used for the tab.
56+
*
57+
* @access public
58+
* @param string $url
59+
* @param string $slug
60+
* @return string
61+
*/
62+
public function hash( $url, $slug ) {
63+
if ( ! in_array( $slug, array(
64+
'comments',
65+
'load-and-scroll',
66+
'restrictions',
67+
'query',
68+
'license'
69+
) ) ) {
70+
return $url;
71+
}
72+
73+
return '#';
74+
} // END hash()
75+
76+
} // END class
77+
78+
} // END if class
79+
80+
return new ALNP_Pro_Preview();

includes/admin/class-alnp-admin.php

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -42,21 +42,25 @@ public function __construct() {
4242
* @version 1.6.0
4343
*/
4444
public function includes() {
45-
include( dirname( __FILE__ ) . '/class-alnp-action-links.php' ); // Action Links
46-
include( dirname( __FILE__ ) . '/class-alnp-admin-assets.php' ); // Admin Assets
47-
include( dirname( __FILE__ ) . '/class-alnp-admin-notices.php' ); // Plugin Notices
45+
include( dirname( __FILE__ ) . '/class-alnp-action-links.php' ); // Action Links
46+
include( dirname( __FILE__ ) . '/class-alnp-admin-assets.php' ); // Admin Assets
47+
include( dirname( __FILE__ ) . '/class-alnp-admin-notices.php' ); // Plugin Notices
4848

4949
if ( apply_filters( 'alnp_enable_admin_help_tab', true ) ) {
50-
include( dirname( __FILE__ ) . '/class-alnp-admin-help.php' ); // Plugin Help Tab
50+
include( dirname( __FILE__ ) . '/class-alnp-admin-help.php' ); // Plugin Help Tab
5151
}
5252

53-
include_once( dirname( __FILE__ ) . '/class-alnp-getting-started.php'); // Getting Started.
54-
include_once( dirname( __FILE__ ) . '/class-alnp-setup-wizard.php'); // Setup Wizard.
55-
include_once( dirname( __FILE__ ) . '/class-alnp-extensions.php'); // Extensions.
53+
include_once( dirname( __FILE__ ) . '/class-alnp-getting-started.php'); // Getting Started.
54+
include_once( dirname( __FILE__ ) . '/class-alnp-setup-wizard.php'); // Setup Wizard.
55+
include_once( dirname( __FILE__ ) . '/class-alnp-extensions.php'); // Extensions.
5656

57-
include( dirname( __FILE__ ) . '/class-alnp-sidebar.php' ); // Sidebar
58-
include( dirname( __FILE__ ) . '/class-alnp-admin-footer.php' ); // Admin Footer
59-
include( dirname( __FILE__ ) . '/class-alnp-privacy.php' ); // Plugin Privacy
57+
if ( ! is_alnp_pro_version_installed() ) {
58+
include_once( dirname( __FILE__ ) . '/class-alnp-admin-pro-preview.php'); // Pro Preview.
59+
}
60+
61+
include( dirname( __FILE__ ) . '/class-alnp-sidebar.php' ); // Sidebar
62+
include( dirname( __FILE__ ) . '/class-alnp-admin-footer.php' ); // Admin Footer
63+
include( dirname( __FILE__ ) . '/class-alnp-privacy.php' ); // Plugin Privacy
6064
} // END includes()
6165

6266
/**

0 commit comments

Comments
 (0)