Version Description
(Released: March 07, 2021) = * Compatibility check up to version 5.7
Download this release
Release Info
Developer | catchthemes |
Plugin | To Top |
Version | 2.2.1 |
Comparing to | |
See all releases |
Code changes from version 2.2 to 2.2.1
- README.txt +129 -127
- admin/inc/CatchThemesThemePlugin.php +484 -484
- languages/to-top-fr_FR.mo +0 -0
- languages/to-top-fr_FR.po +4 -4
- languages/to-top.pot +3 -3
- to-top.php +166 -166
README.txt
CHANGED
@@ -1,127 +1,129 @@
|
|
1 |
-
=== To Top ===
|
2 |
-
Contributors: catchplugins, catchthemes, sakinshrestha, pratikshrestha, maheshmaharjan, dreamsapana
|
3 |
-
Donate link: https://catchplugins.com/plugins/to-top/
|
4 |
-
Tags: to top, scroll up, arrow, button, icon, link to top, scroll, back to top, scroll to top, scroll top, scroll up, simple scroll to top, simple back to top, smooth scroll
|
5 |
-
Requires at least: 4.8
|
6 |
-
Tested up to: 5.
|
7 |
-
Stable tag: trunk
|
8 |
-
License: GNU General Public License, version 3 (GPLv3)
|
9 |
-
License URI: http://www.gnu.org/licenses/gpl-3.0.txt
|
10 |
-
|
11 |
-
To Top is a nifty lightweight plugin. It adds a highly customizable button, which when clicked, scrolls up smoothly to the top of a page.
|
12 |
-
|
13 |
-
== Description ==
|
14 |
-
|
15 |
-
To Top Plugin adds a floating scroll up box at the bottom right side (by default) of the page when scrolled down and, when clicked, rolls smoothly to the top. This is convenient when you have a long page, and you want to give your visitors an easy way to get back to the top.
|
16 |
-
|
17 |
-
When a page or post has heaps of content, visitors have to scroll down to read those content. As they scroll below, all the navigational links go up. When visitors are done with the reading, they need to scroll up to see what else is there on your website. This can be very tedious. To Top Plugin adds a scroll up button that quickly gets visitors to the top of the page in a matter of milliseconds. Also, the transition is smooth and improves user experience. The other great thing about this plugin is you don’t have to touch a single code of your template.
|
18 |
-
|
19 |
-
### Features
|
20 |
-
* Displays an icon when user scrolls down the page
|
21 |
-
* Live Preview via Customizer
|
22 |
-
* Scrolls the page back to top with animation
|
23 |
-
* Set icon/image opacity
|
24 |
-
* Set icon(dashicons) or image as to top button
|
25 |
-
* For icon, set background color, icon color, icon size and icon shape(from square to circle)
|
26 |
-
* Set any image you want
|
27 |
-
* Set image width
|
28 |
-
* Set the location of the icon
|
29 |
-
* Show/hide To Top button in admin pages.
|
30 |
-
* Auto hide
|
31 |
-
* Hide on small devices
|
32 |
-
|
33 |
-
= Premium Support =
|
34 |
-
|
35 |
-
Catch Plugins team does not provide support for the To Top plugin on the WordPress.org forums. Support is provided at [To Top Support Forum](https://catchplugins.com/support-forum/forum/to-top/)
|
36 |
-
|
37 |
-
= Translation =
|
38 |
-
|
39 |
-
To Top plugin is translation ready.
|
40 |
-
|
41 |
-
|
42 |
-
== Installation ==
|
43 |
-
|
44 |
-
You can download and install To Top plugin using the built in WordPress plugin installer. If you download To Top manually, make sure it is uploaded to "/wp-content/plugins/to-top/".
|
45 |
-
|
46 |
-
Activate To Top in the "Plugins" admin panel using the "Activate" link.
|
47 |
-
|
48 |
-
You'll then see To Top dashboard from which you can enable or disable the button as per your need.
|
49 |
-
|
50 |
-
== Screenshots ==
|
51 |
-
|
52 |
-
1. Basic Settings
|
53 |
-
2. Icon Settings
|
54 |
-
3. Image Settings
|
55 |
-
4. Advanced Settings
|
56 |
-
5. Reset Settings
|
57 |
-
|
58 |
-
== Changelog ==
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
*
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
*
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
*
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
Â
|
|
Â
|
1 |
+
=== To Top ===
|
2 |
+
Contributors: catchplugins, catchthemes, sakinshrestha, pratikshrestha, maheshmaharjan, dreamsapana
|
3 |
+
Donate link: https://catchplugins.com/plugins/to-top/
|
4 |
+
Tags: to top, scroll up, arrow, button, icon, link to top, scroll, back to top, scroll to top, scroll top, scroll up, simple scroll to top, simple back to top, smooth scroll
|
5 |
+
Requires at least: 4.8
|
6 |
+
Tested up to: 5.7
|
7 |
+
Stable tag: trunk
|
8 |
+
License: GNU General Public License, version 3 (GPLv3)
|
9 |
+
License URI: http://www.gnu.org/licenses/gpl-3.0.txt
|
10 |
+
|
11 |
+
To Top is a nifty lightweight plugin. It adds a highly customizable button, which when clicked, scrolls up smoothly to the top of a page.
|
12 |
+
|
13 |
+
== Description ==
|
14 |
+
|
15 |
+
To Top Plugin adds a floating scroll up box at the bottom right side (by default) of the page when scrolled down and, when clicked, rolls smoothly to the top. This is convenient when you have a long page, and you want to give your visitors an easy way to get back to the top.
|
16 |
+
|
17 |
+
When a page or post has heaps of content, visitors have to scroll down to read those content. As they scroll below, all the navigational links go up. When visitors are done with the reading, they need to scroll up to see what else is there on your website. This can be very tedious. To Top Plugin adds a scroll up button that quickly gets visitors to the top of the page in a matter of milliseconds. Also, the transition is smooth and improves user experience. The other great thing about this plugin is you don’t have to touch a single code of your template.
|
18 |
+
|
19 |
+
### Features
|
20 |
+
* Displays an icon when user scrolls down the page
|
21 |
+
* Live Preview via Customizer
|
22 |
+
* Scrolls the page back to top with animation
|
23 |
+
* Set icon/image opacity
|
24 |
+
* Set icon(dashicons) or image as to top button
|
25 |
+
* For icon, set background color, icon color, icon size and icon shape(from square to circle)
|
26 |
+
* Set any image you want
|
27 |
+
* Set image width
|
28 |
+
* Set the location of the icon
|
29 |
+
* Show/hide To Top button in admin pages.
|
30 |
+
* Auto hide
|
31 |
+
* Hide on small devices
|
32 |
+
|
33 |
+
= Premium Support =
|
34 |
+
|
35 |
+
Catch Plugins team does not provide support for the To Top plugin on the WordPress.org forums. Support is provided at [To Top Support Forum](https://catchplugins.com/support-forum/forum/to-top/)
|
36 |
+
|
37 |
+
= Translation =
|
38 |
+
|
39 |
+
To Top plugin is translation ready.
|
40 |
+
|
41 |
+
|
42 |
+
== Installation ==
|
43 |
+
|
44 |
+
You can download and install To Top plugin using the built in WordPress plugin installer. If you download To Top manually, make sure it is uploaded to "/wp-content/plugins/to-top/".
|
45 |
+
|
46 |
+
Activate To Top in the "Plugins" admin panel using the "Activate" link.
|
47 |
+
|
48 |
+
You'll then see To Top dashboard from which you can enable or disable the button as per your need.
|
49 |
+
|
50 |
+
== Screenshots ==
|
51 |
+
|
52 |
+
1. Basic Settings
|
53 |
+
2. Icon Settings
|
54 |
+
3. Image Settings
|
55 |
+
4. Advanced Settings
|
56 |
+
5. Reset Settings
|
57 |
+
|
58 |
+
== Changelog ==
|
59 |
+
= 2.2.1 (Released: March 07, 2021) =
|
60 |
+
* Compatibility check up to version 5.7
|
61 |
+
|
62 |
+
= 2.2 (Released: Aug 19, 2020) =
|
63 |
+
* Bug Fixed: Issue in add new theme page (Reported by: derek13)
|
64 |
+
|
65 |
+
= 2.1 (Released: March 17, 2020) =
|
66 |
+
* Compatibility check up to version 5.4
|
67 |
+
|
68 |
+
= 2.0 (Released: November 12, 2019) =
|
69 |
+
* Compatibility check up to version 5.3
|
70 |
+
|
71 |
+
= 1.9 (Released: August 20, 2019) =
|
72 |
+
* Added: Option to turn off Catch Themes and Catch Plugin tabs
|
73 |
+
* Compatibility check up to version 5.2
|
74 |
+
* Updated: Catch Themes and Catch Plugins tabs displaying code
|
75 |
+
|
76 |
+
= 1.8.1 (Released: February 21, 2019) =
|
77 |
+
* Added: French language translation by Hubert
|
78 |
+
|
79 |
+
= 1.8 (Released: February 21, 2019) =
|
80 |
+
* Compatibility check up to Version 5.1
|
81 |
+
|
82 |
+
= 1.7 (Released: December 12, 2018) =
|
83 |
+
* Added: Catch Themes and Catch Plugins tabs in Add themes and Add plugins page respectively
|
84 |
+
* Added: Themes by Catch Themes section under Themes panel in customizer
|
85 |
+
* Compatibility check up to Version 5.0
|
86 |
+
|
87 |
+
= 1.6 (Released: May 07, 2018) =
|
88 |
+
* Compatibility check up to version 4.9.5
|
89 |
+
* Update: Moved domain from catchthemes.com to catchplugins.com
|
90 |
+
|
91 |
+
= 1.5.6 =
|
92 |
+
* Replaced: div with span (Reported by: jacktester)
|
93 |
+
|
94 |
+
= 1.5.5 =
|
95 |
+
* Bug Fixed: Translation issue, replace top-up text domain to to-top in to-top-admin-display.php file ( Reported By: Guillaume Blet )
|
96 |
+
|
97 |
+
= 1.5.4 =
|
98 |
+
* Compatibility check up to version 4.9
|
99 |
+
|
100 |
+
= 1.5.3 =
|
101 |
+
* Compatibility check up to version 4.8
|
102 |
+
|
103 |
+
= 1.5.2 =
|
104 |
+
* Bug Fixed: Default value of 'margin_x' in customizer ( Reported By: sherrif02 )
|
105 |
+
* Bug Fixed: Condition check for CSS ( Reported By: sherrif02 )
|
106 |
+
* Updated: Make image link protocol-less http:// or https:// to // ( Reported By: pianoworld )
|
107 |
+
|
108 |
+
= 1.5.1 =
|
109 |
+
* Bug Fixed: array_merge issue in some php versions
|
110 |
+
|
111 |
+
= 1.5 =
|
112 |
+
* Bug Fixed: Display on hover without scrolling issue
|
113 |
+
|
114 |
+
= 1.4 =
|
115 |
+
* Compatibility check up to version 4.7
|
116 |
+
|
117 |
+
= 1.3 =
|
118 |
+
* Compatibility check up to version 4.6
|
119 |
+
|
120 |
+
= 1.2 =
|
121 |
+
* Changed: http to https in links
|
122 |
+
* Bug Fixed: Sanitize callback, saving only changed value and other to null.
|
123 |
+
|
124 |
+
= 1.1 =
|
125 |
+
* Added Genericons Support
|
126 |
+
* Added Font Awesome Support
|
127 |
+
|
128 |
+
= 1.0 =
|
129 |
+
* Initial Release
|
admin/inc/CatchThemesThemePlugin.php
CHANGED
@@ -1,484 +1,484 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
class CatchThemesThemePlugin {
|
4 |
-
public function __construct() {
|
5 |
-
remove_action( 'wp_ajax_query-themes', array( $this, 'wp_ajax_query_themes' ), 1 );
|
6 |
-
add_action( 'wp_ajax_query-themes', array( $this, 'wp_ajax_custom_query_themes' ), 1 );
|
7 |
-
|
8 |
-
add_action( 'admin_enqueue_scripts', array( $this, 'our_themes_script' ) );
|
9 |
-
|
10 |
-
if ( ! is_multisite() ) {
|
11 |
-
add_action( 'customize_register', array( $this, 'customize_register' ) );
|
12 |
-
}
|
13 |
-
|
14 |
-
global $wp_customize;
|
15 |
-
remove_action( 'wp_ajax_customize_load_themes', array( $wp_customize, 'handle_load_themes_request' ) );
|
16 |
-
add_action( 'wp_ajax_customize_load_themes', array( $this, 'handle_load_themes_request' ) );
|
17 |
-
|
18 |
-
add_filter( 'install_plugins_tabs', array( $this, 'add_our_plugins_tab' ), 1 );
|
19 |
-
add_filter( 'install_plugins_table_api_args_catchplugins', array( $this, 'catchplugins' ), 1 );
|
20 |
-
add_action( 'install_plugins_catchplugins', array( $this, 'plugins_table' ) );
|
21 |
-
}
|
22 |
-
|
23 |
-
/* Adds Catch Themes tab in Add Theme page to show all themes by Catch Themes in wordpress.org
|
24 |
-
* taken from wp-admin/includes/ajax-action.php wp_ajax_query_themes().
|
25 |
-
* Ajax handler for getting themes from themes_api().
|
26 |
-
*
|
27 |
-
* @since 3.9.0
|
28 |
-
*
|
29 |
-
* @global array $themes_allowedtags
|
30 |
-
* @global array $theme_field_defaults
|
31 |
-
*/
|
32 |
-
public function wp_ajax_custom_query_themes() {
|
33 |
-
global $themes_allowedtags, $theme_field_defaults;
|
34 |
-
|
35 |
-
if ( ! current_user_can( 'install_themes' ) ) {
|
36 |
-
wp_send_json_error();
|
37 |
-
}
|
38 |
-
|
39 |
-
$args = wp_parse_args(
|
40 |
-
wp_unslash( $_REQUEST['request'] ),
|
41 |
-
array(
|
42 |
-
'per_page' => 20,
|
43 |
-
'fields' => array_merge(
|
44 |
-
(array) $theme_field_defaults,
|
45 |
-
array(
|
46 |
-
'reviews_url' => true, // Explicitly request the reviews URL to be linked from the Add Themes screen.
|
47 |
-
)
|
48 |
-
),
|
49 |
-
)
|
50 |
-
);
|
51 |
-
|
52 |
-
if ( isset( $args['browse'] ) && 'catchthemes' === $args['browse'] && ! isset( $args['user'] ) ) {
|
53 |
-
$args['author'] = 'catchthemes';
|
54 |
-
unset( $args['browse'] );
|
55 |
-
}
|
56 |
-
|
57 |
-
if ( isset( $args['browse'] ) && 'favorites' === $args['browse'] && ! isset( $args['user'] ) ) {
|
58 |
-
$user = get_user_option( 'wporg_favorites' );
|
59 |
-
if ( $user ) {
|
60 |
-
$args['user'] = $user;
|
61 |
-
}
|
62 |
-
}
|
63 |
-
|
64 |
-
$old_filter = isset( $args['browse'] ) ? $args['browse'] : 'search';
|
65 |
-
|
66 |
-
/** This filter is documented in wp-admin/includes/class-wp-theme-install-list-table.php */
|
67 |
-
$args = apply_filters( 'install_themes_table_api_args_' . $old_filter, $args );
|
68 |
-
|
69 |
-
$api = themes_api( 'query_themes', $args );
|
70 |
-
|
71 |
-
if ( is_wp_error( $api ) ) {
|
72 |
-
wp_send_json_error();
|
73 |
-
}
|
74 |
-
|
75 |
-
$update_php = network_admin_url( 'update.php?action=install-theme' );
|
76 |
-
foreach ( $api->themes as &$theme ) {
|
77 |
-
$theme->install_url = add_query_arg(
|
78 |
-
array(
|
79 |
-
'theme' => $theme->slug,
|
80 |
-
'_wpnonce' => wp_create_nonce( 'install-theme_' . $theme->slug ),
|
81 |
-
),
|
82 |
-
$update_php
|
83 |
-
);
|
84 |
-
|
85 |
-
if ( current_user_can( 'switch_themes' ) ) {
|
86 |
-
if ( is_multisite() ) {
|
87 |
-
$theme->activate_url = add_query_arg(
|
88 |
-
array(
|
89 |
-
'action' => 'enable',
|
90 |
-
'_wpnonce' => wp_create_nonce( 'enable-theme_' . $theme->slug ),
|
91 |
-
'theme' => $theme->slug,
|
92 |
-
),
|
93 |
-
network_admin_url( 'themes.php' )
|
94 |
-
);
|
95 |
-
} else {
|
96 |
-
$theme->activate_url = add_query_arg(
|
97 |
-
array(
|
98 |
-
'action' => 'activate',
|
99 |
-
'_wpnonce' => wp_create_nonce( 'switch-theme_' . $theme->slug ),
|
100 |
-
'stylesheet' => $theme->slug,
|
101 |
-
),
|
102 |
-
admin_url( 'themes.php' )
|
103 |
-
);
|
104 |
-
}
|
105 |
-
}
|
106 |
-
|
107 |
-
if ( ! is_multisite() && current_user_can( 'edit_theme_options' ) && current_user_can( 'customize' ) ) {
|
108 |
-
$theme->customize_url = add_query_arg(
|
109 |
-
array(
|
110 |
-
'return' => urlencode( network_admin_url( 'theme-install.php', 'relative' ) ),
|
111 |
-
),
|
112 |
-
wp_customize_url( $theme->slug )
|
113 |
-
);
|
114 |
-
}
|
115 |
-
|
116 |
-
$theme->name = wp_kses( $theme->name, $themes_allowedtags );
|
117 |
-
$theme->author = wp_kses( $theme->author['display_name'], $themes_allowedtags );
|
118 |
-
$theme->version = wp_kses( $theme->version, $themes_allowedtags );
|
119 |
-
$theme->description = wp_kses( $theme->description, $themes_allowedtags );
|
120 |
-
|
121 |
-
$theme->stars = wp_star_rating(
|
122 |
-
array(
|
123 |
-
'rating' => $theme->rating,
|
124 |
-
'type' => 'percent',
|
125 |
-
'number' => $theme->num_ratings,
|
126 |
-
'echo' => false,
|
127 |
-
)
|
128 |
-
);
|
129 |
-
|
130 |
-
$theme->num_ratings = number_format_i18n( $theme->num_ratings );
|
131 |
-
$theme->preview_url = set_url_scheme( $theme->preview_url );
|
132 |
-
$theme->compatible_wp = is_wp_version_compatible( $theme->requires );
|
133 |
-
$theme->compatible_php = is_php_version_compatible( $theme->requires_php );
|
134 |
-
|
135 |
-
}
|
136 |
-
|
137 |
-
wp_send_json_success( $api );
|
138 |
-
}
|
139 |
-
|
140 |
-
public function our_themes_script( $hook_suffix ) {
|
141 |
-
|
142 |
-
if ( 'theme-install.php' === $hook_suffix ) {
|
143 |
-
wp_enqueue_script( 'our-themes-script', plugin_dir_url( __FILE__ ) . '../js/our-themes.js', array( 'jquery' ), '2018-05-16' );
|
144 |
-
}
|
145 |
-
}
|
146 |
-
|
147 |
-
/* Add Catch Themes Section in Theme in Customizer */
|
148 |
-
public function customize_register( $wp_customize ) {
|
149 |
-
$wp_customize->add_section(
|
150 |
-
new WP_Customize_Themes_Section(
|
151 |
-
$wp_customize,
|
152 |
-
'catchthemes',
|
153 |
-
array(
|
154 |
-
'title' => __( 'Themes by CatchThemes', 'catch-themes-demo-import' ),
|
155 |
-
'action' => 'catchthemes',
|
156 |
-
'capability' => 'install_themes',
|
157 |
-
'panel' => 'themes',
|
158 |
-
'priority' => 6,
|
159 |
-
)
|
160 |
-
)
|
161 |
-
);
|
162 |
-
}
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
/**
|
168 |
-
* Load themes into the theme browsing/installation UI.
|
169 |
-
* taken from wp-includes/cllass-wp-customize-manager.php
|
170 |
-
* @since 4.9.0
|
171 |
-
*/
|
172 |
-
public function handle_load_themes_request() {
|
173 |
-
check_ajax_referer( 'switch_themes', 'nonce' );
|
174 |
-
if ( ! current_user_can( 'switch_themes' ) ) {
|
175 |
-
wp_die( -1 );
|
176 |
-
}
|
177 |
-
|
178 |
-
if ( empty( $_POST['theme_action'] ) ) {
|
179 |
-
wp_send_json_error( 'missing_theme_action' );
|
180 |
-
}
|
181 |
-
$theme_action = sanitize_key( $_POST['theme_action'] );
|
182 |
-
$themes = array();
|
183 |
-
$args = array();
|
184 |
-
|
185 |
-
// Define query filters based on user input.
|
186 |
-
if ( ! array_key_exists( 'search', $_POST ) ) {
|
187 |
-
$args['search'] = '';
|
188 |
-
} else {
|
189 |
-
$args['search'] = sanitize_text_field( wp_unslash( $_POST['search'] ) );
|
190 |
-
}
|
191 |
-
|
192 |
-
if ( ! array_key_exists( 'tags', $_POST ) ) {
|
193 |
-
$args['tag'] = '';
|
194 |
-
} else {
|
195 |
-
$args['tag'] = array_map( 'sanitize_text_field', wp_unslash( (array) $_POST['tags'] ) );
|
196 |
-
}
|
197 |
-
|
198 |
-
if ( ! array_key_exists( 'page', $_POST ) ) {
|
199 |
-
$args['page'] = 1;
|
200 |
-
} else {
|
201 |
-
$args['page'] = absint( $_POST['page'] );
|
202 |
-
}
|
203 |
-
|
204 |
-
require_once ABSPATH . 'wp-admin/includes/theme.php';
|
205 |
-
|
206 |
-
if ( 'installed' === $theme_action ) {
|
207 |
-
|
208 |
-
// Load all installed themes from wp_prepare_themes_for_js().
|
209 |
-
$themes = array( 'themes' => wp_prepare_themes_for_js() );
|
210 |
-
foreach ( $themes['themes'] as &$theme ) {
|
211 |
-
$theme['type'] = 'installed';
|
212 |
-
$theme['active'] = ( isset( $_POST['customized_theme'] ) && $_POST['customized_theme'] === $theme['id'] );
|
213 |
-
}
|
214 |
-
} elseif ( 'catchthemes' === $theme_action ) {
|
215 |
-
|
216 |
-
// Load WordPress.org themes from the .org API and normalize data to match installed theme objects.
|
217 |
-
if ( ! current_user_can( 'install_themes' ) ) {
|
218 |
-
wp_die( -1 );
|
219 |
-
}
|
220 |
-
|
221 |
-
// Arguments for all queries.
|
222 |
-
$wporg_args = array(
|
223 |
-
'per_page' => 100,
|
224 |
-
'fields' => array(
|
225 |
-
'reviews_url' => true, // Explicitly request the reviews URL to be linked from the customizer.
|
226 |
-
),
|
227 |
-
);
|
228 |
-
|
229 |
-
$args = array_merge( $wporg_args, $args );
|
230 |
-
|
231 |
-
if ( '' === $args['search'] && '' === $args['tag'] ) {
|
232 |
-
$args['browse'] = 'new'; // Sort by latest themes by default.
|
233 |
-
}
|
234 |
-
|
235 |
-
$args['author'] = 'catchthemes';
|
236 |
-
|
237 |
-
// Load themes from the .org API.
|
238 |
-
$themes = themes_api( 'query_themes', $args );
|
239 |
-
if ( is_wp_error( $themes ) ) {
|
240 |
-
wp_send_json_error();
|
241 |
-
}
|
242 |
-
|
243 |
-
// This list matches the allowed tags in wp-admin/includes/theme-install.php.
|
244 |
-
$themes_allowedtags = array_fill_keys(
|
245 |
-
array( 'a', 'abbr', 'acronym', 'code', 'pre', 'em', 'strong', 'div', 'p', 'ul', 'ol', 'li', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'img' ),
|
246 |
-
array()
|
247 |
-
);
|
248 |
-
$themes_allowedtags['a'] = array_fill_keys( array( 'href', 'title', 'target' ), true );
|
249 |
-
$themes_allowedtags['acronym']['title'] = true;
|
250 |
-
$themes_allowedtags['abbr']['title'] = true;
|
251 |
-
$themes_allowedtags['img'] = array_fill_keys( array( 'src', 'class', 'alt' ), true );
|
252 |
-
|
253 |
-
// Prepare a list of installed themes to check against before the loop.
|
254 |
-
$installed_themes = array();
|
255 |
-
$wp_themes = wp_get_themes();
|
256 |
-
foreach ( $wp_themes as $theme ) {
|
257 |
-
$installed_themes[] = $theme->get_stylesheet();
|
258 |
-
}
|
259 |
-
$update_php = network_admin_url( 'update.php?action=install-theme' );
|
260 |
-
|
261 |
-
// Set up properties for themes available on WordPress.org.
|
262 |
-
foreach ( $themes->themes as &$theme ) {
|
263 |
-
$theme->install_url = add_query_arg(
|
264 |
-
array(
|
265 |
-
'theme' => $theme->slug,
|
266 |
-
'_wpnonce' => wp_create_nonce( 'install-theme_' . $theme->slug ),
|
267 |
-
),
|
268 |
-
$update_php
|
269 |
-
);
|
270 |
-
|
271 |
-
$theme->name = wp_kses( $theme->name, $themes_allowedtags );
|
272 |
-
$theme->version = wp_kses( $theme->version, $themes_allowedtags );
|
273 |
-
$theme->description = wp_kses( $theme->description, $themes_allowedtags );
|
274 |
-
$theme->stars = wp_star_rating(
|
275 |
-
array(
|
276 |
-
'rating' => $theme->rating,
|
277 |
-
'type' => 'percent',
|
278 |
-
'number' => $theme->num_ratings,
|
279 |
-
'echo' => false,
|
280 |
-
)
|
281 |
-
);
|
282 |
-
$theme->num_ratings = number_format_i18n( $theme->num_ratings );
|
283 |
-
$theme->preview_url = set_url_scheme( $theme->preview_url );
|
284 |
-
|
285 |
-
// Handle themes that are already installed as installed themes.
|
286 |
-
if ( in_array( $theme->slug, $installed_themes, true ) ) {
|
287 |
-
$theme->type = 'installed';
|
288 |
-
} else {
|
289 |
-
$theme->type = $theme_action;
|
290 |
-
}
|
291 |
-
|
292 |
-
// Set active based on customized theme.
|
293 |
-
$theme->active = ( isset( $_POST['customized_theme'] ) && $_POST['customized_theme'] === $theme->slug );
|
294 |
-
|
295 |
-
// Map available theme properties to installed theme properties.
|
296 |
-
$theme->id = $theme->slug;
|
297 |
-
$theme->screenshot = array( $theme->screenshot_url );
|
298 |
-
$theme->authorAndUri = wp_kses( $theme->author['display_name'], $themes_allowedtags );
|
299 |
-
$theme->compatibleWP = is_wp_version_compatible( $theme->requires ); // phpcs:ignore WordPress.NamingConventions.ValidVariableName
|
300 |
-
$theme->compatiblePHP = is_php_version_compatible( $theme->requires_php ); // phpcs:ignore WordPress.NamingConventions.ValidVariableName
|
301 |
-
|
302 |
-
if ( isset( $theme->parent ) ) {
|
303 |
-
$theme->parent = $theme->parent['slug'];
|
304 |
-
} else {
|
305 |
-
$theme->parent = false;
|
306 |
-
}
|
307 |
-
unset( $theme->slug );
|
308 |
-
unset( $theme->screenshot_url );
|
309 |
-
unset( $theme->author );
|
310 |
-
} // End foreach().
|
311 |
-
} elseif ( 'wporg' === $theme_action ) {
|
312 |
-
|
313 |
-
// Load WordPress.org themes from the .org API and normalize data to match installed theme objects.
|
314 |
-
if ( ! current_user_can( 'install_themes' ) ) {
|
315 |
-
wp_die( -1 );
|
316 |
-
}
|
317 |
-
|
318 |
-
// Arguments for all queries.
|
319 |
-
$wporg_args = array(
|
320 |
-
'per_page' => 100,
|
321 |
-
'fields' => array(
|
322 |
-
'reviews_url' => true, // Explicitly request the reviews URL to be linked from the customizer.
|
323 |
-
),
|
324 |
-
);
|
325 |
-
|
326 |
-
$args = array_merge( $wporg_args, $args );
|
327 |
-
|
328 |
-
if ( '' === $args['search'] && '' === $args['tag'] ) {
|
329 |
-
$args['browse'] = 'new'; // Sort by latest themes by default.
|
330 |
-
}
|
331 |
-
|
332 |
-
// Load themes from the .org API.
|
333 |
-
$themes = themes_api( 'query_themes', $args );
|
334 |
-
if ( is_wp_error( $themes ) ) {
|
335 |
-
wp_send_json_error();
|
336 |
-
}
|
337 |
-
|
338 |
-
// This list matches the allowed tags in wp-admin/includes/theme-install.php.
|
339 |
-
$themes_allowedtags = array_fill_keys(
|
340 |
-
array( 'a', 'abbr', 'acronym', 'code', 'pre', 'em', 'strong', 'div', 'p', 'ul', 'ol', 'li', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'img' ),
|
341 |
-
array()
|
342 |
-
);
|
343 |
-
$themes_allowedtags['a'] = array_fill_keys( array( 'href', 'title', 'target' ), true );
|
344 |
-
$themes_allowedtags['acronym']['title'] = true;
|
345 |
-
$themes_allowedtags['abbr']['title'] = true;
|
346 |
-
$themes_allowedtags['img'] = array_fill_keys( array( 'src', 'class', 'alt' ), true );
|
347 |
-
|
348 |
-
// Prepare a list of installed themes to check against before the loop.
|
349 |
-
$installed_themes = array();
|
350 |
-
$wp_themes = wp_get_themes();
|
351 |
-
foreach ( $wp_themes as $theme ) {
|
352 |
-
$installed_themes[] = $theme->get_stylesheet();
|
353 |
-
}
|
354 |
-
$update_php = network_admin_url( 'update.php?action=install-theme' );
|
355 |
-
|
356 |
-
// Set up properties for themes available on WordPress.org.
|
357 |
-
foreach ( $themes->themes as &$theme ) {
|
358 |
-
$theme->install_url = add_query_arg(
|
359 |
-
array(
|
360 |
-
'theme' => $theme->slug,
|
361 |
-
'_wpnonce' => wp_create_nonce( 'install-theme_' . $theme->slug ),
|
362 |
-
),
|
363 |
-
$update_php
|
364 |
-
);
|
365 |
-
|
366 |
-
$theme->name = wp_kses( $theme->name, $themes_allowedtags );
|
367 |
-
$theme->version = wp_kses( $theme->version, $themes_allowedtags );
|
368 |
-
$theme->description = wp_kses( $theme->description, $themes_allowedtags );
|
369 |
-
$theme->stars = wp_star_rating(
|
370 |
-
array(
|
371 |
-
'rating' => $theme->rating,
|
372 |
-
'type' => 'percent',
|
373 |
-
'number' => $theme->num_ratings,
|
374 |
-
'echo' => false,
|
375 |
-
)
|
376 |
-
);
|
377 |
-
$theme->num_ratings = number_format_i18n( $theme->num_ratings );
|
378 |
-
$theme->preview_url = set_url_scheme( $theme->preview_url );
|
379 |
-
|
380 |
-
// Handle themes that are already installed as installed themes.
|
381 |
-
if ( in_array( $theme->slug, $installed_themes, true ) ) {
|
382 |
-
$theme->type = 'installed';
|
383 |
-
} else {
|
384 |
-
$theme->type = $theme_action;
|
385 |
-
}
|
386 |
-
|
387 |
-
// Set active based on customized theme.
|
388 |
-
$theme->active = ( isset( $_POST['customized_theme'] ) && $_POST['customized_theme'] === $theme->slug );
|
389 |
-
|
390 |
-
// Map available theme properties to installed theme properties.
|
391 |
-
$theme->id = $theme->slug;
|
392 |
-
$theme->screenshot = array( $theme->screenshot_url );
|
393 |
-
$theme->authorAndUri = wp_kses( $theme->author['display_name'], $themes_allowedtags );
|
394 |
-
$theme->compatibleWP = is_wp_version_compatible( $theme->requires ); // phpcs:ignore WordPress.NamingConventions.ValidVariableName
|
395 |
-
$theme->compatiblePHP = is_php_version_compatible( $theme->requires_php ); // phpcs:ignore WordPress.NamingConventions.ValidVariableName
|
396 |
-
|
397 |
-
if ( isset( $theme->parent ) ) {
|
398 |
-
$theme->parent = $theme->parent['slug'];
|
399 |
-
} else {
|
400 |
-
$theme->parent = false;
|
401 |
-
}
|
402 |
-
unset( $theme->slug );
|
403 |
-
unset( $theme->screenshot_url );
|
404 |
-
unset( $theme->author );
|
405 |
-
} // End foreach().
|
406 |
-
} // End if().
|
407 |
-
|
408 |
-
/**
|
409 |
-
* Filters the theme data loaded in the customizer.
|
410 |
-
*
|
411 |
-
* This allows theme data to be loading from an external source,
|
412 |
-
* or modification of data loaded from `wp_prepare_themes_for_js()`
|
413 |
-
* or WordPress.org via `themes_api()`.
|
414 |
-
*
|
415 |
-
* @since 4.9.0
|
416 |
-
*
|
417 |
-
* @see wp_prepare_themes_for_js()
|
418 |
-
* @see themes_api()
|
419 |
-
* @see WP_Customize_Manager::__construct()
|
420 |
-
*
|
421 |
-
* @param array $themes Nested array of theme data.
|
422 |
-
* @param array $args List of arguments, such as page, search term, and tags to query for.
|
423 |
-
* @param WP_Customize_Manager $manager Instance of Customize manager.
|
424 |
-
*/
|
425 |
-
$themes = apply_filters( 'customize_load_themes', $themes, $args, $wp_customize );
|
426 |
-
|
427 |
-
wp_send_json_success( $themes );
|
428 |
-
}
|
429 |
-
|
430 |
-
/* Plugins */
|
431 |
-
/* Adds Catch Plugins tab in Add Plugin page to show all plugins by Catch Plugins in wordpress.org */
|
432 |
-
public function add_our_plugins_tab( $tabs ) {
|
433 |
-
// Add our filter here
|
434 |
-
$tabs['catchplugins'] = _x( 'Catch Plugins', 'Plugin Installer' );
|
435 |
-
|
436 |
-
return $tabs;
|
437 |
-
}
|
438 |
-
|
439 |
-
public function catchplugins() {
|
440 |
-
/* From CORE Start */
|
441 |
-
global $paged, $tab;
|
442 |
-
wp_reset_vars( array( 'tab' ) );
|
443 |
-
|
444 |
-
$defined_class = new WP_Plugin_Install_List_Table();
|
445 |
-
$paged = $defined_class->get_pagenum();
|
446 |
-
|
447 |
-
$per_page = 30;
|
448 |
-
//$installed_plugins = catch_get_installed_plugins();
|
449 |
-
|
450 |
-
$args = array(
|
451 |
-
'page' => $paged,
|
452 |
-
'per_page' => $per_page,
|
453 |
-
'fields' => array(
|
454 |
-
'last_updated' => true,
|
455 |
-
'icons' => true,
|
456 |
-
'active_installs' => true,
|
457 |
-
),
|
458 |
-
// Send the locale and installed plugin slugs to the API so it can provide context-sensitive results.
|
459 |
-
'locale' => get_user_locale(),
|
460 |
-
//'installed_plugins' => array_keys( $installed_plugins ),
|
461 |
-
);
|
462 |
-
/* From CORE End */
|
463 |
-
|
464 |
-
// Add author filter for our plugins
|
465 |
-
$args['author'] = 'catchplugins';
|
466 |
-
|
467 |
-
return $args;
|
468 |
-
}
|
469 |
-
|
470 |
-
public function plugins_table() {
|
471 |
-
global $wp_list_table;
|
472 |
-
printf(
|
473 |
-
'<p class="catch-plugins-list">' . __( 'You can use any of our free plugins or premium plugins from <a href="%s" target="_blank">Catch Plugins</a>' ) . '.</p>',
|
474 |
-
'https://catchplugins.com/'
|
475 |
-
);
|
476 |
-
?>
|
477 |
-
<form id="plugin-filter" method="post">
|
478 |
-
<?php $wp_list_table->display(); ?>
|
479 |
-
</form>
|
480 |
-
<?php
|
481 |
-
}
|
482 |
-
}
|
483 |
-
|
484 |
-
$catchthemes_theme_plugin = new CatchThemesThemePlugin();
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class CatchThemesThemePlugin {
|
4 |
+
public function __construct() {
|
5 |
+
remove_action( 'wp_ajax_query-themes', array( $this, 'wp_ajax_query_themes' ), 1 );
|
6 |
+
add_action( 'wp_ajax_query-themes', array( $this, 'wp_ajax_custom_query_themes' ), 1 );
|
7 |
+
|
8 |
+
add_action( 'admin_enqueue_scripts', array( $this, 'our_themes_script' ) );
|
9 |
+
|
10 |
+
if ( ! is_multisite() ) {
|
11 |
+
add_action( 'customize_register', array( $this, 'customize_register' ) );
|
12 |
+
}
|
13 |
+
|
14 |
+
global $wp_customize;
|
15 |
+
remove_action( 'wp_ajax_customize_load_themes', array( $wp_customize, 'handle_load_themes_request' ) );
|
16 |
+
add_action( 'wp_ajax_customize_load_themes', array( $this, 'handle_load_themes_request' ) );
|
17 |
+
|
18 |
+
add_filter( 'install_plugins_tabs', array( $this, 'add_our_plugins_tab' ), 1 );
|
19 |
+
add_filter( 'install_plugins_table_api_args_catchplugins', array( $this, 'catchplugins' ), 1 );
|
20 |
+
add_action( 'install_plugins_catchplugins', array( $this, 'plugins_table' ) );
|
21 |
+
}
|
22 |
+
|
23 |
+
/* Adds Catch Themes tab in Add Theme page to show all themes by Catch Themes in wordpress.org
|
24 |
+
* taken from wp-admin/includes/ajax-action.php wp_ajax_query_themes().
|
25 |
+
* Ajax handler for getting themes from themes_api().
|
26 |
+
*
|
27 |
+
* @since 3.9.0
|
28 |
+
*
|
29 |
+
* @global array $themes_allowedtags
|
30 |
+
* @global array $theme_field_defaults
|
31 |
+
*/
|
32 |
+
public function wp_ajax_custom_query_themes() {
|
33 |
+
global $themes_allowedtags, $theme_field_defaults;
|
34 |
+
|
35 |
+
if ( ! current_user_can( 'install_themes' ) ) {
|
36 |
+
wp_send_json_error();
|
37 |
+
}
|
38 |
+
|
39 |
+
$args = wp_parse_args(
|
40 |
+
wp_unslash( $_REQUEST['request'] ),
|
41 |
+
array(
|
42 |
+
'per_page' => 20,
|
43 |
+
'fields' => array_merge(
|
44 |
+
(array) $theme_field_defaults,
|
45 |
+
array(
|
46 |
+
'reviews_url' => true, // Explicitly request the reviews URL to be linked from the Add Themes screen.
|
47 |
+
)
|
48 |
+
),
|
49 |
+
)
|
50 |
+
);
|
51 |
+
|
52 |
+
if ( isset( $args['browse'] ) && 'catchthemes' === $args['browse'] && ! isset( $args['user'] ) ) {
|
53 |
+
$args['author'] = 'catchthemes';
|
54 |
+
unset( $args['browse'] );
|
55 |
+
}
|
56 |
+
|
57 |
+
if ( isset( $args['browse'] ) && 'favorites' === $args['browse'] && ! isset( $args['user'] ) ) {
|
58 |
+
$user = get_user_option( 'wporg_favorites' );
|
59 |
+
if ( $user ) {
|
60 |
+
$args['user'] = $user;
|
61 |
+
}
|
62 |
+
}
|
63 |
+
|
64 |
+
$old_filter = isset( $args['browse'] ) ? $args['browse'] : 'search';
|
65 |
+
|
66 |
+
/** This filter is documented in wp-admin/includes/class-wp-theme-install-list-table.php */
|
67 |
+
$args = apply_filters( 'install_themes_table_api_args_' . $old_filter, $args );
|
68 |
+
|
69 |
+
$api = themes_api( 'query_themes', $args );
|
70 |
+
|
71 |
+
if ( is_wp_error( $api ) ) {
|
72 |
+
wp_send_json_error();
|
73 |
+
}
|
74 |
+
|
75 |
+
$update_php = network_admin_url( 'update.php?action=install-theme' );
|
76 |
+
foreach ( $api->themes as &$theme ) {
|
77 |
+
$theme->install_url = add_query_arg(
|
78 |
+
array(
|
79 |
+
'theme' => $theme->slug,
|
80 |
+
'_wpnonce' => wp_create_nonce( 'install-theme_' . $theme->slug ),
|
81 |
+
),
|
82 |
+
$update_php
|
83 |
+
);
|
84 |
+
|
85 |
+
if ( current_user_can( 'switch_themes' ) ) {
|
86 |
+
if ( is_multisite() ) {
|
87 |
+
$theme->activate_url = add_query_arg(
|
88 |
+
array(
|
89 |
+
'action' => 'enable',
|
90 |
+
'_wpnonce' => wp_create_nonce( 'enable-theme_' . $theme->slug ),
|
91 |
+
'theme' => $theme->slug,
|
92 |
+
),
|
93 |
+
network_admin_url( 'themes.php' )
|
94 |
+
);
|
95 |
+
} else {
|
96 |
+
$theme->activate_url = add_query_arg(
|
97 |
+
array(
|
98 |
+
'action' => 'activate',
|
99 |
+
'_wpnonce' => wp_create_nonce( 'switch-theme_' . $theme->slug ),
|
100 |
+
'stylesheet' => $theme->slug,
|
101 |
+
),
|
102 |
+
admin_url( 'themes.php' )
|
103 |
+
);
|
104 |
+
}
|
105 |
+
}
|
106 |
+
|
107 |
+
if ( ! is_multisite() && current_user_can( 'edit_theme_options' ) && current_user_can( 'customize' ) ) {
|
108 |
+
$theme->customize_url = add_query_arg(
|
109 |
+
array(
|
110 |
+
'return' => urlencode( network_admin_url( 'theme-install.php', 'relative' ) ),
|
111 |
+
),
|
112 |
+
wp_customize_url( $theme->slug )
|
113 |
+
);
|
114 |
+
}
|
115 |
+
|
116 |
+
$theme->name = wp_kses( $theme->name, $themes_allowedtags );
|
117 |
+
$theme->author = wp_kses( $theme->author['display_name'], $themes_allowedtags );
|
118 |
+
$theme->version = wp_kses( $theme->version, $themes_allowedtags );
|
119 |
+
$theme->description = wp_kses( $theme->description, $themes_allowedtags );
|
120 |
+
|
121 |
+
$theme->stars = wp_star_rating(
|
122 |
+
array(
|
123 |
+
'rating' => $theme->rating,
|
124 |
+
'type' => 'percent',
|
125 |
+
'number' => $theme->num_ratings,
|
126 |
+
'echo' => false,
|
127 |
+
)
|
128 |
+
);
|
129 |
+
|
130 |
+
$theme->num_ratings = number_format_i18n( $theme->num_ratings );
|
131 |
+
$theme->preview_url = set_url_scheme( $theme->preview_url );
|
132 |
+
$theme->compatible_wp = is_wp_version_compatible( $theme->requires );
|
133 |
+
$theme->compatible_php = is_php_version_compatible( $theme->requires_php );
|
134 |
+
|
135 |
+
}
|
136 |
+
|
137 |
+
wp_send_json_success( $api );
|
138 |
+
}
|
139 |
+
|
140 |
+
public function our_themes_script( $hook_suffix ) {
|
141 |
+
|
142 |
+
if ( 'theme-install.php' === $hook_suffix ) {
|
143 |
+
wp_enqueue_script( 'our-themes-script', plugin_dir_url( __FILE__ ) . '../js/our-themes.js', array( 'jquery' ), '2018-05-16' );
|
144 |
+
}
|
145 |
+
}
|
146 |
+
|
147 |
+
/* Add Catch Themes Section in Theme in Customizer */
|
148 |
+
public function customize_register( $wp_customize ) {
|
149 |
+
$wp_customize->add_section(
|
150 |
+
new WP_Customize_Themes_Section(
|
151 |
+
$wp_customize,
|
152 |
+
'catchthemes',
|
153 |
+
array(
|
154 |
+
'title' => __( 'Themes by CatchThemes', 'catch-themes-demo-import' ),
|
155 |
+
'action' => 'catchthemes',
|
156 |
+
'capability' => 'install_themes',
|
157 |
+
'panel' => 'themes',
|
158 |
+
'priority' => 6,
|
159 |
+
)
|
160 |
+
)
|
161 |
+
);
|
162 |
+
}
|
163 |
+
|
164 |
+
|
165 |
+
|
166 |
+
|
167 |
+
/**
|
168 |
+
* Load themes into the theme browsing/installation UI.
|
169 |
+
* taken from wp-includes/cllass-wp-customize-manager.php
|
170 |
+
* @since 4.9.0
|
171 |
+
*/
|
172 |
+
public function handle_load_themes_request() {
|
173 |
+
check_ajax_referer( 'switch_themes', 'nonce' );
|
174 |
+
if ( ! current_user_can( 'switch_themes' ) ) {
|
175 |
+
wp_die( -1 );
|
176 |
+
}
|
177 |
+
|
178 |
+
if ( empty( $_POST['theme_action'] ) ) {
|
179 |
+
wp_send_json_error( 'missing_theme_action' );
|
180 |
+
}
|
181 |
+
$theme_action = sanitize_key( $_POST['theme_action'] );
|
182 |
+
$themes = array();
|
183 |
+
$args = array();
|
184 |
+
|
185 |
+
// Define query filters based on user input.
|
186 |
+
if ( ! array_key_exists( 'search', $_POST ) ) {
|
187 |
+
$args['search'] = '';
|
188 |
+
} else {
|
189 |
+
$args['search'] = sanitize_text_field( wp_unslash( $_POST['search'] ) );
|
190 |
+
}
|
191 |
+
|
192 |
+
if ( ! array_key_exists( 'tags', $_POST ) ) {
|
193 |
+
$args['tag'] = '';
|
194 |
+
} else {
|
195 |
+
$args['tag'] = array_map( 'sanitize_text_field', wp_unslash( (array) $_POST['tags'] ) );
|
196 |
+
}
|
197 |
+
|
198 |
+
if ( ! array_key_exists( 'page', $_POST ) ) {
|
199 |
+
$args['page'] = 1;
|
200 |
+
} else {
|
201 |
+
$args['page'] = absint( $_POST['page'] );
|
202 |
+
}
|
203 |
+
|
204 |
+
require_once ABSPATH . 'wp-admin/includes/theme.php';
|
205 |
+
|
206 |
+
if ( 'installed' === $theme_action ) {
|
207 |
+
|
208 |
+
// Load all installed themes from wp_prepare_themes_for_js().
|
209 |
+
$themes = array( 'themes' => wp_prepare_themes_for_js() );
|
210 |
+
foreach ( $themes['themes'] as &$theme ) {
|
211 |
+
$theme['type'] = 'installed';
|
212 |
+
$theme['active'] = ( isset( $_POST['customized_theme'] ) && $_POST['customized_theme'] === $theme['id'] );
|
213 |
+
}
|
214 |
+
} elseif ( 'catchthemes' === $theme_action ) {
|
215 |
+
|
216 |
+
// Load WordPress.org themes from the .org API and normalize data to match installed theme objects.
|
217 |
+
if ( ! current_user_can( 'install_themes' ) ) {
|
218 |
+
wp_die( -1 );
|
219 |
+
}
|
220 |
+
|
221 |
+
// Arguments for all queries.
|
222 |
+
$wporg_args = array(
|
223 |
+
'per_page' => 100,
|
224 |
+
'fields' => array(
|
225 |
+
'reviews_url' => true, // Explicitly request the reviews URL to be linked from the customizer.
|
226 |
+
),
|
227 |
+
);
|
228 |
+
|
229 |
+
$args = array_merge( $wporg_args, $args );
|
230 |
+
|
231 |
+
if ( '' === $args['search'] && '' === $args['tag'] ) {
|
232 |
+
$args['browse'] = 'new'; // Sort by latest themes by default.
|
233 |
+
}
|
234 |
+
|
235 |
+
$args['author'] = 'catchthemes';
|
236 |
+
|
237 |
+
// Load themes from the .org API.
|
238 |
+
$themes = themes_api( 'query_themes', $args );
|
239 |
+
if ( is_wp_error( $themes ) ) {
|
240 |
+
wp_send_json_error();
|
241 |
+
}
|
242 |
+
|
243 |
+
// This list matches the allowed tags in wp-admin/includes/theme-install.php.
|
244 |
+
$themes_allowedtags = array_fill_keys(
|
245 |
+
array( 'a', 'abbr', 'acronym', 'code', 'pre', 'em', 'strong', 'div', 'p', 'ul', 'ol', 'li', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'img' ),
|
246 |
+
array()
|
247 |
+
);
|
248 |
+
$themes_allowedtags['a'] = array_fill_keys( array( 'href', 'title', 'target' ), true );
|
249 |
+
$themes_allowedtags['acronym']['title'] = true;
|
250 |
+
$themes_allowedtags['abbr']['title'] = true;
|
251 |
+
$themes_allowedtags['img'] = array_fill_keys( array( 'src', 'class', 'alt' ), true );
|
252 |
+
|
253 |
+
// Prepare a list of installed themes to check against before the loop.
|
254 |
+
$installed_themes = array();
|
255 |
+
$wp_themes = wp_get_themes();
|
256 |
+
foreach ( $wp_themes as $theme ) {
|
257 |
+
$installed_themes[] = $theme->get_stylesheet();
|
258 |
+
}
|
259 |
+
$update_php = network_admin_url( 'update.php?action=install-theme' );
|
260 |
+
|
261 |
+
// Set up properties for themes available on WordPress.org.
|
262 |
+
foreach ( $themes->themes as &$theme ) {
|
263 |
+
$theme->install_url = add_query_arg(
|
264 |
+
array(
|
265 |
+
'theme' => $theme->slug,
|
266 |
+
'_wpnonce' => wp_create_nonce( 'install-theme_' . $theme->slug ),
|
267 |
+
),
|
268 |
+
$update_php
|
269 |
+
);
|
270 |
+
|
271 |
+
$theme->name = wp_kses( $theme->name, $themes_allowedtags );
|
272 |
+
$theme->version = wp_kses( $theme->version, $themes_allowedtags );
|
273 |
+
$theme->description = wp_kses( $theme->description, $themes_allowedtags );
|
274 |
+
$theme->stars = wp_star_rating(
|
275 |
+
array(
|
276 |
+
'rating' => $theme->rating,
|
277 |
+
'type' => 'percent',
|
278 |
+
'number' => $theme->num_ratings,
|
279 |
+
'echo' => false,
|
280 |
+
)
|
281 |
+
);
|
282 |
+
$theme->num_ratings = number_format_i18n( $theme->num_ratings );
|
283 |
+
$theme->preview_url = set_url_scheme( $theme->preview_url );
|
284 |
+
|
285 |
+
// Handle themes that are already installed as installed themes.
|
286 |
+
if ( in_array( $theme->slug, $installed_themes, true ) ) {
|
287 |
+
$theme->type = 'installed';
|
288 |
+
} else {
|
289 |
+
$theme->type = $theme_action;
|
290 |
+
}
|
291 |
+
|
292 |
+
// Set active based on customized theme.
|
293 |
+
$theme->active = ( isset( $_POST['customized_theme'] ) && $_POST['customized_theme'] === $theme->slug );
|
294 |
+
|
295 |
+
// Map available theme properties to installed theme properties.
|
296 |
+
$theme->id = $theme->slug;
|
297 |
+
$theme->screenshot = array( $theme->screenshot_url );
|
298 |
+
$theme->authorAndUri = wp_kses( $theme->author['display_name'], $themes_allowedtags );
|
299 |
+
$theme->compatibleWP = is_wp_version_compatible( $theme->requires ); // phpcs:ignore WordPress.NamingConventions.ValidVariableName
|
300 |
+
$theme->compatiblePHP = is_php_version_compatible( $theme->requires_php ); // phpcs:ignore WordPress.NamingConventions.ValidVariableName
|
301 |
+
|
302 |
+
if ( isset( $theme->parent ) ) {
|
303 |
+
$theme->parent = $theme->parent['slug'];
|
304 |
+
} else {
|
305 |
+
$theme->parent = false;
|
306 |
+
}
|
307 |
+
unset( $theme->slug );
|
308 |
+
unset( $theme->screenshot_url );
|
309 |
+
unset( $theme->author );
|
310 |
+
} // End foreach().
|
311 |
+
} elseif ( 'wporg' === $theme_action ) {
|
312 |
+
|
313 |
+
// Load WordPress.org themes from the .org API and normalize data to match installed theme objects.
|
314 |
+
if ( ! current_user_can( 'install_themes' ) ) {
|
315 |
+
wp_die( -1 );
|
316 |
+
}
|
317 |
+
|
318 |
+
// Arguments for all queries.
|
319 |
+
$wporg_args = array(
|
320 |
+
'per_page' => 100,
|
321 |
+
'fields' => array(
|
322 |
+
'reviews_url' => true, // Explicitly request the reviews URL to be linked from the customizer.
|
323 |
+
),
|
324 |
+
);
|
325 |
+
|
326 |
+
$args = array_merge( $wporg_args, $args );
|
327 |
+
|
328 |
+
if ( '' === $args['search'] && '' === $args['tag'] ) {
|
329 |
+
$args['browse'] = 'new'; // Sort by latest themes by default.
|
330 |
+
}
|
331 |
+
|
332 |
+
// Load themes from the .org API.
|
333 |
+
$themes = themes_api( 'query_themes', $args );
|
334 |
+
if ( is_wp_error( $themes ) ) {
|
335 |
+
wp_send_json_error();
|
336 |
+
}
|
337 |
+
|
338 |
+
// This list matches the allowed tags in wp-admin/includes/theme-install.php.
|
339 |
+
$themes_allowedtags = array_fill_keys(
|
340 |
+
array( 'a', 'abbr', 'acronym', 'code', 'pre', 'em', 'strong', 'div', 'p', 'ul', 'ol', 'li', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'img' ),
|
341 |
+
array()
|
342 |
+
);
|
343 |
+
$themes_allowedtags['a'] = array_fill_keys( array( 'href', 'title', 'target' ), true );
|
344 |
+
$themes_allowedtags['acronym']['title'] = true;
|
345 |
+
$themes_allowedtags['abbr']['title'] = true;
|
346 |
+
$themes_allowedtags['img'] = array_fill_keys( array( 'src', 'class', 'alt' ), true );
|
347 |
+
|
348 |
+
// Prepare a list of installed themes to check against before the loop.
|
349 |
+
$installed_themes = array();
|
350 |
+
$wp_themes = wp_get_themes();
|
351 |
+
foreach ( $wp_themes as $theme ) {
|
352 |
+
$installed_themes[] = $theme->get_stylesheet();
|
353 |
+
}
|
354 |
+
$update_php = network_admin_url( 'update.php?action=install-theme' );
|
355 |
+
|
356 |
+
// Set up properties for themes available on WordPress.org.
|
357 |
+
foreach ( $themes->themes as &$theme ) {
|
358 |
+
$theme->install_url = add_query_arg(
|
359 |
+
array(
|
360 |
+
'theme' => $theme->slug,
|
361 |
+
'_wpnonce' => wp_create_nonce( 'install-theme_' . $theme->slug ),
|
362 |
+
),
|
363 |
+
$update_php
|
364 |
+
);
|
365 |
+
|
366 |
+
$theme->name = wp_kses( $theme->name, $themes_allowedtags );
|
367 |
+
$theme->version = wp_kses( $theme->version, $themes_allowedtags );
|
368 |
+
$theme->description = wp_kses( $theme->description, $themes_allowedtags );
|
369 |
+
$theme->stars = wp_star_rating(
|
370 |
+
array(
|
371 |
+
'rating' => $theme->rating,
|
372 |
+
'type' => 'percent',
|
373 |
+
'number' => $theme->num_ratings,
|
374 |
+
'echo' => false,
|
375 |
+
)
|
376 |
+
);
|
377 |
+
$theme->num_ratings = number_format_i18n( $theme->num_ratings );
|
378 |
+
$theme->preview_url = set_url_scheme( $theme->preview_url );
|
379 |
+
|
380 |
+
// Handle themes that are already installed as installed themes.
|
381 |
+
if ( in_array( $theme->slug, $installed_themes, true ) ) {
|
382 |
+
$theme->type = 'installed';
|
383 |
+
} else {
|
384 |
+
$theme->type = $theme_action;
|
385 |
+
}
|
386 |
+
|
387 |
+
// Set active based on customized theme.
|
388 |
+
$theme->active = ( isset( $_POST['customized_theme'] ) && $_POST['customized_theme'] === $theme->slug );
|
389 |
+
|
390 |
+
// Map available theme properties to installed theme properties.
|
391 |
+
$theme->id = $theme->slug;
|
392 |
+
$theme->screenshot = array( $theme->screenshot_url );
|
393 |
+
$theme->authorAndUri = wp_kses( $theme->author['display_name'], $themes_allowedtags );
|
394 |
+
$theme->compatibleWP = is_wp_version_compatible( $theme->requires ); // phpcs:ignore WordPress.NamingConventions.ValidVariableName
|
395 |
+
$theme->compatiblePHP = is_php_version_compatible( $theme->requires_php ); // phpcs:ignore WordPress.NamingConventions.ValidVariableName
|
396 |
+
|
397 |
+
if ( isset( $theme->parent ) ) {
|
398 |
+
$theme->parent = $theme->parent['slug'];
|
399 |
+
} else {
|
400 |
+
$theme->parent = false;
|
401 |
+
}
|
402 |
+
unset( $theme->slug );
|
403 |
+
unset( $theme->screenshot_url );
|
404 |
+
unset( $theme->author );
|
405 |
+
} // End foreach().
|
406 |
+
} // End if().
|
407 |
+
|
408 |
+
/**
|
409 |
+
* Filters the theme data loaded in the customizer.
|
410 |
+
*
|
411 |
+
* This allows theme data to be loading from an external source,
|
412 |
+
* or modification of data loaded from `wp_prepare_themes_for_js()`
|
413 |
+
* or WordPress.org via `themes_api()`.
|
414 |
+
*
|
415 |
+
* @since 4.9.0
|
416 |
+
*
|
417 |
+
* @see wp_prepare_themes_for_js()
|
418 |
+
* @see themes_api()
|
419 |
+
* @see WP_Customize_Manager::__construct()
|
420 |
+
*
|
421 |
+
* @param array $themes Nested array of theme data.
|
422 |
+
* @param array $args List of arguments, such as page, search term, and tags to query for.
|
423 |
+
* @param WP_Customize_Manager $manager Instance of Customize manager.
|
424 |
+
*/
|
425 |
+
$themes = apply_filters( 'customize_load_themes', $themes, $args, $wp_customize );
|
426 |
+
|
427 |
+
wp_send_json_success( $themes );
|
428 |
+
}
|
429 |
+
|
430 |
+
/* Plugins */
|
431 |
+
/* Adds Catch Plugins tab in Add Plugin page to show all plugins by Catch Plugins in wordpress.org */
|
432 |
+
public function add_our_plugins_tab( $tabs ) {
|
433 |
+
// Add our filter here
|
434 |
+
$tabs['catchplugins'] = _x( 'Catch Plugins', 'Plugin Installer' );
|
435 |
+
|
436 |
+
return $tabs;
|
437 |
+
}
|
438 |
+
|
439 |
+
public function catchplugins() {
|
440 |
+
/* From CORE Start */
|
441 |
+
global $paged, $tab;
|
442 |
+
wp_reset_vars( array( 'tab' ) );
|
443 |
+
|
444 |
+
$defined_class = new WP_Plugin_Install_List_Table();
|
445 |
+
$paged = $defined_class->get_pagenum();
|
446 |
+
|
447 |
+
$per_page = 30;
|
448 |
+
//$installed_plugins = catch_get_installed_plugins();
|
449 |
+
|
450 |
+
$args = array(
|
451 |
+
'page' => $paged,
|
452 |
+
'per_page' => $per_page,
|
453 |
+
'fields' => array(
|
454 |
+
'last_updated' => true,
|
455 |
+
'icons' => true,
|
456 |
+
'active_installs' => true,
|
457 |
+
),
|
458 |
+
// Send the locale and installed plugin slugs to the API so it can provide context-sensitive results.
|
459 |
+
'locale' => get_user_locale(),
|
460 |
+
//'installed_plugins' => array_keys( $installed_plugins ),
|
461 |
+
);
|
462 |
+
/* From CORE End */
|
463 |
+
|
464 |
+
// Add author filter for our plugins
|
465 |
+
$args['author'] = 'catchplugins';
|
466 |
+
|
467 |
+
return $args;
|
468 |
+
}
|
469 |
+
|
470 |
+
public function plugins_table() {
|
471 |
+
global $wp_list_table;
|
472 |
+
printf(
|
473 |
+
'<p class="catch-plugins-list">' . __( 'You can use any of our free plugins or premium plugins from <a href="%s" target="_blank">Catch Plugins</a>' ) . '.</p>',
|
474 |
+
'https://catchplugins.com/'
|
475 |
+
);
|
476 |
+
?>
|
477 |
+
<form id="plugin-filter" method="post">
|
478 |
+
<?php $wp_list_table->display(); ?>
|
479 |
+
</form>
|
480 |
+
<?php
|
481 |
+
}
|
482 |
+
}
|
483 |
+
|
484 |
+
$catchthemes_theme_plugin = new CatchThemesThemePlugin();
|
languages/to-top-fr_FR.mo
CHANGED
Binary file
|
languages/to-top-fr_FR.po
CHANGED
@@ -1,11 +1,11 @@
|
|
1 |
-
# Copyright (C) 2017-
|
2 |
Â
# This file is distributed under the GNU General Public License v3.
|
3 |
Â
msgid ""
|
4 |
Â
msgstr ""
|
5 |
Â
"Project-Id-Version: To Top\n"
|
6 |
Â
"Report-Msgid-Bugs-To: https://wordpress.org/tags/_s\n"
|
7 |
-
"POT-Creation-Date:
|
8 |
-
"PO-Revision-Date:
|
9 |
Â
"Last-Translator: Hubert Desrues <hubert.desrues@gmail.com>\n"
|
10 |
Â
"Language-Team: Français\n"
|
11 |
Â
"Language: fr_FR\n"
|
@@ -13,7 +13,7 @@ msgstr ""
|
|
13 |
Â
"Content-Type: text/plain; charset=UTF-8\n"
|
14 |
Â
"Content-Transfer-Encoding: 8bit\n"
|
15 |
Â
"Plural-Forms: nplurals=2; plural=n > 1;\n"
|
16 |
-
"X-Generator: Poedit 2.4.
|
17 |
Â
"X-Poedit-KeywordsList: __;_e;_n:1,2;_x:1,2c;esc_attr_e;esc_attr__;_nx;"
|
18 |
Â
"esc_html__;esc_html_e\n"
|
19 |
Â
"X-Poedit-Basepath: .\n"
|
1 |
+
# Copyright (C) 2017-2021 Catch Plugins
|
2 |
Â
# This file is distributed under the GNU General Public License v3.
|
3 |
Â
msgid ""
|
4 |
Â
msgstr ""
|
5 |
Â
"Project-Id-Version: To Top\n"
|
6 |
Â
"Report-Msgid-Bugs-To: https://wordpress.org/tags/_s\n"
|
7 |
+
"POT-Creation-Date: 2021-03-07 13:49-0800\n"
|
8 |
+
"PO-Revision-Date: 2021-03-07 13:49-0800\n"
|
9 |
Â
"Last-Translator: Hubert Desrues <hubert.desrues@gmail.com>\n"
|
10 |
Â
"Language-Team: Français\n"
|
11 |
Â
"Language: fr_FR\n"
|
13 |
Â
"Content-Type: text/plain; charset=UTF-8\n"
|
14 |
Â
"Content-Transfer-Encoding: 8bit\n"
|
15 |
Â
"Plural-Forms: nplurals=2; plural=n > 1;\n"
|
16 |
+
"X-Generator: Poedit 2.4.2\n"
|
17 |
Â
"X-Poedit-KeywordsList: __;_e;_n:1,2;_x:1,2c;esc_attr_e;esc_attr__;_nx;"
|
18 |
Â
"esc_html__;esc_html_e\n"
|
19 |
Â
"X-Poedit-Basepath: .\n"
|
languages/to-top.pot
CHANGED
@@ -1,11 +1,11 @@
|
|
1 |
-
# Copyright (C) 2017-
|
2 |
Â
# This file is distributed under the GNU General Public License v3.
|
3 |
Â
#, fuzzy
|
4 |
Â
msgid ""
|
5 |
Â
msgstr ""
|
6 |
Â
"Project-Id-Version: To Top\n"
|
7 |
Â
"Report-Msgid-Bugs-To: https://wordpress.org/tags/_s\n"
|
8 |
-
"POT-Creation-Date:
|
9 |
Â
"PO-Revision-Date: 2016-12-07 23:04-0500\n"
|
10 |
Â
"Last-Translator: Sakin Shrestha <info@catchplugins.com>\n"
|
11 |
Â
"Language-Team: Catch Plugins <info@catchplugins.com>\n"
|
@@ -14,7 +14,7 @@ msgstr ""
|
|
14 |
Â
"Content-Type: text/plain; charset=UTF-8\n"
|
15 |
Â
"Content-Transfer-Encoding: 8bit\n"
|
16 |
Â
"Plural-Forms: nplurals=2; plural=n != 1;\n"
|
17 |
-
"X-Generator: Poedit 2.4.
|
18 |
Â
"X-Poedit-KeywordsList: __;_e;_n:1,2;_x:1,2c;esc_attr_e;esc_attr__;_nx;"
|
19 |
Â
"esc_html__;esc_html_e\n"
|
20 |
Â
"X-Poedit-Basepath: .\n"
|
1 |
+
# Copyright (C) 2017-2021 Catch Plugins
|
2 |
Â
# This file is distributed under the GNU General Public License v3.
|
3 |
Â
#, fuzzy
|
4 |
Â
msgid ""
|
5 |
Â
msgstr ""
|
6 |
Â
"Project-Id-Version: To Top\n"
|
7 |
Â
"Report-Msgid-Bugs-To: https://wordpress.org/tags/_s\n"
|
8 |
+
"POT-Creation-Date: 2021-03-07 13:49-0800\n"
|
9 |
Â
"PO-Revision-Date: 2016-12-07 23:04-0500\n"
|
10 |
Â
"Last-Translator: Sakin Shrestha <info@catchplugins.com>\n"
|
11 |
Â
"Language-Team: Catch Plugins <info@catchplugins.com>\n"
|
14 |
Â
"Content-Type: text/plain; charset=UTF-8\n"
|
15 |
Â
"Content-Transfer-Encoding: 8bit\n"
|
16 |
Â
"Plural-Forms: nplurals=2; plural=n != 1;\n"
|
17 |
+
"X-Generator: Poedit 2.4.2\n"
|
18 |
Â
"X-Poedit-KeywordsList: __;_e;_n:1,2;_x:1,2c;esc_attr_e;esc_attr__;_nx;"
|
19 |
Â
"esc_html__;esc_html_e\n"
|
20 |
Â
"X-Poedit-Basepath: .\n"
|
to-top.php
CHANGED
@@ -1,166 +1,166 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Plugin Name: To Top
|
4 |
-
* Plugin URI: https://catchplugins.com/plugins/to-top/
|
5 |
-
* Description: To Top plugin allows the visitor as well as admin to easily scroll back to the top of the page, with fully customizable options and ability to use image.
|
6 |
-
* Author: Catch Plugins
|
7 |
-
* Author URI: https://catchplugins.com/
|
8 |
-
* Version: 2.2
|
9 |
-
* License: GNU General Public License, version 3 (GPLv3)
|
10 |
-
* License URI: http://www.gnu.org/licenses/gpl-3.0.txt
|
11 |
-
* Text Domain: to-top
|
12 |
-
* Domain Path: languages
|
13 |
-
*
|
14 |
-
* Copyright (C) 2012-2018 Catch Plugins, (info@catchplugins.com)
|
15 |
-
*
|
16 |
-
* To Top Plugin is free software; you can redistribute it and/or modify
|
17 |
-
* it under the terms of the GNU General Public License as published by
|
18 |
-
* the Free Software Foundation; either version 3 of the License, or
|
19 |
-
* (at your option) any later version.
|
20 |
-
*
|
21 |
-
* This program is distributed in the hope that it will be useful,
|
22 |
-
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
23 |
-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
24 |
-
* GNU General Public License for more details.
|
25 |
-
*
|
26 |
-
* You should have received a copy of the GNU General Public License
|
27 |
-
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
28 |
-
*
|
29 |
-
* @package To_Top
|
30 |
-
* @link catchplugins.com
|
31 |
-
* @author Catch Plugins
|
32 |
-
* @version 1.5
|
33 |
-
*/
|
34 |
-
|
35 |
-
// If this file is called directly, abort.
|
36 |
-
if ( ! defined( 'WPINC' ) ) {
|
37 |
-
die;
|
38 |
-
}
|
39 |
-
|
40 |
-
// Define Version
|
41 |
-
define( 'TOTOP_VERSION', '2.2' );
|
42 |
-
|
43 |
-
// The URL of the directory that contains the plugin
|
44 |
-
if ( ! defined( 'TOTOP_URL' ) ) {
|
45 |
-
define( 'TOTOP_URL', plugin_dir_url( __FILE__ ) );
|
46 |
-
}
|
47 |
-
|
48 |
-
|
49 |
-
// The absolute path of the directory that contains the file
|
50 |
-
if ( ! defined( 'TOTOP_PATH' ) ) {
|
51 |
-
define( 'TOTOP_PATH', plugin_dir_path( __FILE__ ) );
|
52 |
-
}
|
53 |
-
|
54 |
-
// Gets the path to a plugin file or directory, relative to the plugins directory, without the leading and trailing slashes.
|
55 |
-
if ( ! defined( 'TOTOP_BASENAME' ) ) {
|
56 |
-
define( 'TOTOP_BASENAME', plugin_basename( __FILE__ ) );
|
57 |
-
}
|
58 |
-
|
59 |
-
function activate_to_top() {
|
60 |
-
require_once plugin_dir_path( __FILE__ ) . 'includes/class-to-top-activator.php';
|
61 |
-
To_Top_Activator::activate();
|
62 |
-
}
|
63 |
-
|
64 |
-
/**
|
65 |
-
* The code that runs during plugin deactivation.
|
66 |
-
* This action is documented in includes/class-to-top-deactivator.php
|
67 |
-
*/
|
68 |
-
function deactivate_to_top() {
|
69 |
-
require_once plugin_dir_path( __FILE__ ) . 'includes/class-to-top-deactivator.php';
|
70 |
-
To_Top_Deactivator::deactivate();
|
71 |
-
}
|
72 |
-
|
73 |
-
register_activation_hook( __FILE__, 'activate_to_top' );
|
74 |
-
register_deactivation_hook( __FILE__, 'deactivate_to_top' );
|
75 |
-
|
76 |
-
/**
|
77 |
-
* The core plugin class that is used to define internationalization,
|
78 |
-
* admin-specific hooks, and public-facing site hooks.
|
79 |
-
*/
|
80 |
-
require plugin_dir_path( __FILE__ ) . 'includes/class-to-top.php';
|
81 |
-
|
82 |
-
/**
|
83 |
-
* Begins execution of the plugin.
|
84 |
-
*
|
85 |
-
* Since everything within the plugin is registered via hooks,
|
86 |
-
* then kicking off the plugin from this point in the file does
|
87 |
-
* not affect the page life cycle.
|
88 |
-
*
|
89 |
-
* @since 1.0
|
90 |
-
*/
|
91 |
-
function run_to_top() {
|
92 |
-
|
93 |
-
$plugin = new To_Top();
|
94 |
-
$plugin->run();
|
95 |
-
|
96 |
-
}
|
97 |
-
run_to_top();
|
98 |
-
|
99 |
-
/**
|
100 |
-
* Returns the options array for Top options
|
101 |
-
*
|
102 |
-
* @since 1.0
|
103 |
-
*/
|
104 |
-
function to_top_get_options() {
|
105 |
-
$defaults = to_top_default_options();
|
106 |
-
$options = get_option( 'to_top_options', $defaults );
|
107 |
-
|
108 |
-
return wp_parse_args( $options, $defaults );
|
109 |
-
}
|
110 |
-
|
111 |
-
/**
|
112 |
-
* Return array of default options
|
113 |
-
*
|
114 |
-
* @since 1.0
|
115 |
-
* @return array default options.
|
116 |
-
*/
|
117 |
-
function to_top_default_options( $option = null ) {
|
118 |
-
$default_options = array(
|
119 |
-
//Basic Settings
|
120 |
-
'scroll_offset' => '100',
|
121 |
-
'icon_opacity' => '50',
|
122 |
-
'style' => 'icon',
|
123 |
-
|
124 |
-
//Icon Settings
|
125 |
-
'icon_type' => 'dashicons-arrow-up-alt2',
|
126 |
-
'icon_color' => '#ffffff',
|
127 |
-
'icon_bg_color' => '#000000',
|
128 |
-
'icon_size' => '32',
|
129 |
-
'border_radius' => '5',
|
130 |
-
|
131 |
-
//Image Settings
|
132 |
-
'image' => plugin_dir_url( __FILE__ ) . 'admin/images/default.png',
|
133 |
-
'image_width' => '65',
|
134 |
-
'image_alt' => '',
|
135 |
-
|
136 |
-
//Advanced Settings
|
137 |
-
'location' => 'bottom-right',
|
138 |
-
'margin_x' => '20',
|
139 |
-
'margin_y' => '20',
|
140 |
-
'show_on_admin' => 0,
|
141 |
-
'enable_autohide' => 0,
|
142 |
-
'autohide_time' => '2',
|
143 |
-
'enable_hide_small_device' => 0,
|
144 |
-
'small_device_max_width' => '640',
|
145 |
-
|
146 |
-
//Reset Settings
|
147 |
-
'reset' => 0,
|
148 |
-
);
|
149 |
-
|
150 |
-
if ( null == $option ) {
|
151 |
-
return apply_filters( 'to_top_options', $default_options );
|
152 |
-
} else {
|
153 |
-
return $default_options[ $option ];
|
154 |
-
}
|
155 |
-
}
|
156 |
-
|
157 |
-
/* CTP tabs removal options */
|
158 |
-
require plugin_dir_path( __FILE__ ) . 'admin/inc/ctp-tabs-removal.php';
|
159 |
-
|
160 |
-
$ctp_options = ctp_get_options();
|
161 |
-
if ( 1 == $ctp_options['theme_plugin_tabs'] ) {
|
162 |
-
/* Adds Catch Themes tab in Add theme page and Themes by Catch Themes in Customizer's change theme option. */
|
163 |
-
if ( ! class_exists( 'CatchThemesThemePlugin' ) && ! function_exists( 'add_our_plugins_tab' ) ) {
|
164 |
-
require plugin_dir_path( __FILE__ ) . 'admin/inc/CatchThemesThemePlugin.php';
|
165 |
-
}
|
166 |
-
}
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Plugin Name: To Top
|
4 |
+
* Plugin URI: https://catchplugins.com/plugins/to-top/
|
5 |
+
* Description: To Top plugin allows the visitor as well as admin to easily scroll back to the top of the page, with fully customizable options and ability to use image.
|
6 |
+
* Author: Catch Plugins
|
7 |
+
* Author URI: https://catchplugins.com/
|
8 |
+
* Version: 2.2.1
|
9 |
+
* License: GNU General Public License, version 3 (GPLv3)
|
10 |
+
* License URI: http://www.gnu.org/licenses/gpl-3.0.txt
|
11 |
+
* Text Domain: to-top
|
12 |
+
* Domain Path: languages
|
13 |
+
*
|
14 |
+
* Copyright (C) 2012-2018 Catch Plugins, (info@catchplugins.com)
|
15 |
+
*
|
16 |
+
* To Top Plugin is free software; you can redistribute it and/or modify
|
17 |
+
* it under the terms of the GNU General Public License as published by
|
18 |
+
* the Free Software Foundation; either version 3 of the License, or
|
19 |
+
* (at your option) any later version.
|
20 |
+
*
|
21 |
+
* This program is distributed in the hope that it will be useful,
|
22 |
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
23 |
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
24 |
+
* GNU General Public License for more details.
|
25 |
+
*
|
26 |
+
* You should have received a copy of the GNU General Public License
|
27 |
+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
28 |
+
*
|
29 |
+
* @package To_Top
|
30 |
+
* @link catchplugins.com
|
31 |
+
* @author Catch Plugins
|
32 |
+
* @version 1.5
|
33 |
+
*/
|
34 |
+
|
35 |
+
// If this file is called directly, abort.
|
36 |
+
if ( ! defined( 'WPINC' ) ) {
|
37 |
+
die;
|
38 |
+
}
|
39 |
+
|
40 |
+
// Define Version
|
41 |
+
define( 'TOTOP_VERSION', '2.2.1' );
|
42 |
+
|
43 |
+
// The URL of the directory that contains the plugin
|
44 |
+
if ( ! defined( 'TOTOP_URL' ) ) {
|
45 |
+
define( 'TOTOP_URL', plugin_dir_url( __FILE__ ) );
|
46 |
+
}
|
47 |
+
|
48 |
+
|
49 |
+
// The absolute path of the directory that contains the file
|
50 |
+
if ( ! defined( 'TOTOP_PATH' ) ) {
|
51 |
+
define( 'TOTOP_PATH', plugin_dir_path( __FILE__ ) );
|
52 |
+
}
|
53 |
+
|
54 |
+
// Gets the path to a plugin file or directory, relative to the plugins directory, without the leading and trailing slashes.
|
55 |
+
if ( ! defined( 'TOTOP_BASENAME' ) ) {
|
56 |
+
define( 'TOTOP_BASENAME', plugin_basename( __FILE__ ) );
|
57 |
+
}
|
58 |
+
|
59 |
+
function activate_to_top() {
|
60 |
+
require_once plugin_dir_path( __FILE__ ) . 'includes/class-to-top-activator.php';
|
61 |
+
To_Top_Activator::activate();
|
62 |
+
}
|
63 |
+
|
64 |
+
/**
|
65 |
+
* The code that runs during plugin deactivation.
|
66 |
+
* This action is documented in includes/class-to-top-deactivator.php
|
67 |
+
*/
|
68 |
+
function deactivate_to_top() {
|
69 |
+
require_once plugin_dir_path( __FILE__ ) . 'includes/class-to-top-deactivator.php';
|
70 |
+
To_Top_Deactivator::deactivate();
|
71 |
+
}
|
72 |
+
|
73 |
+
register_activation_hook( __FILE__, 'activate_to_top' );
|
74 |
+
register_deactivation_hook( __FILE__, 'deactivate_to_top' );
|
75 |
+
|
76 |
+
/**
|
77 |
+
* The core plugin class that is used to define internationalization,
|
78 |
+
* admin-specific hooks, and public-facing site hooks.
|
79 |
+
*/
|
80 |
+
require plugin_dir_path( __FILE__ ) . 'includes/class-to-top.php';
|
81 |
+
|
82 |
+
/**
|
83 |
+
* Begins execution of the plugin.
|
84 |
+
*
|
85 |
+
* Since everything within the plugin is registered via hooks,
|
86 |
+
* then kicking off the plugin from this point in the file does
|
87 |
+
* not affect the page life cycle.
|
88 |
+
*
|
89 |
+
* @since 1.0
|
90 |
+
*/
|
91 |
+
function run_to_top() {
|
92 |
+
|
93 |
+
$plugin = new To_Top();
|
94 |
+
$plugin->run();
|
95 |
+
|
96 |
+
}
|
97 |
+
run_to_top();
|
98 |
+
|
99 |
+
/**
|
100 |
+
* Returns the options array for Top options
|
101 |
+
*
|
102 |
+
* @since 1.0
|
103 |
+
*/
|
104 |
+
function to_top_get_options() {
|
105 |
+
$defaults = to_top_default_options();
|
106 |
+
$options = get_option( 'to_top_options', $defaults );
|
107 |
+
|
108 |
+
return wp_parse_args( $options, $defaults );
|
109 |
+
}
|
110 |
+
|
111 |
+
/**
|
112 |
+
* Return array of default options
|
113 |
+
*
|
114 |
+
* @since 1.0
|
115 |
+
* @return array default options.
|
116 |
+
*/
|
117 |
+
function to_top_default_options( $option = null ) {
|
118 |
+
$default_options = array(
|
119 |
+
//Basic Settings
|
120 |
+
'scroll_offset' => '100',
|
121 |
+
'icon_opacity' => '50',
|
122 |
+
'style' => 'icon',
|
123 |
+
|
124 |
+
//Icon Settings
|
125 |
+
'icon_type' => 'dashicons-arrow-up-alt2',
|
126 |
+
'icon_color' => '#ffffff',
|
127 |
+
'icon_bg_color' => '#000000',
|
128 |
+
'icon_size' => '32',
|
129 |
+
'border_radius' => '5',
|
130 |
+
|
131 |
+
//Image Settings
|
132 |
+
'image' => plugin_dir_url( __FILE__ ) . 'admin/images/default.png',
|
133 |
+
'image_width' => '65',
|
134 |
+
'image_alt' => '',
|
135 |
+
|
136 |
+
//Advanced Settings
|
137 |
+
'location' => 'bottom-right',
|
138 |
+
'margin_x' => '20',
|
139 |
+
'margin_y' => '20',
|
140 |
+
'show_on_admin' => 0,
|
141 |
+
'enable_autohide' => 0,
|
142 |
+
'autohide_time' => '2',
|
143 |
+
'enable_hide_small_device' => 0,
|
144 |
+
'small_device_max_width' => '640',
|
145 |
+
|
146 |
+
//Reset Settings
|
147 |
+
'reset' => 0,
|
148 |
+
);
|
149 |
+
|
150 |
+
if ( null == $option ) {
|
151 |
+
return apply_filters( 'to_top_options', $default_options );
|
152 |
+
} else {
|
153 |
+
return $default_options[ $option ];
|
154 |
+
}
|
155 |
+
}
|
156 |
+
|
157 |
+
/* CTP tabs removal options */
|
158 |
+
require plugin_dir_path( __FILE__ ) . 'admin/inc/ctp-tabs-removal.php';
|
159 |
+
|
160 |
+
$ctp_options = ctp_get_options();
|
161 |
+
if ( 1 == $ctp_options['theme_plugin_tabs'] ) {
|
162 |
+
/* Adds Catch Themes tab in Add theme page and Themes by Catch Themes in Customizer's change theme option. */
|
163 |
+
if ( ! class_exists( 'CatchThemesThemePlugin' ) && ! function_exists( 'add_our_plugins_tab' ) ) {
|
164 |
+
require plugin_dir_path( __FILE__ ) . 'admin/inc/CatchThemesThemePlugin.php';
|
165 |
+
}
|
166 |
+
}
|