PluginProbe
Whols – Wholesale Prices and B2B Store Solution for WooCommerce / trunk
Whols – Wholesale Prices and B2B Store Solution for WooCommerce vtrunk
2.4.12 2.4.11 trunk 1.1.2 1.1.3 1.1.4 1.1.5 1.1.6 1.1.7 1.1.8 1.1.9 1.2.0 1.2.1 1.2.2 1.2.4 1.2.5 1.2.6 1.2.7 1.2.8 1.2.9 1.3.0 1.3.1 1.3.2 1.3.3 1.3.4 All 55 releases
whols / includes / Frontend.php

Frontend.php in Whols – Wholesale Prices and B2B Store Solution for WooCommerce trunk, at includes/Frontend.php

66 lines 1.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Whols Frontend
4 *
5 * @since 1.0.0
6 */
7
8 namespace Whols;
9
10 /**
11 * Frontend class.
12 */
13 class Frontend {
14 public $version = '';
15
16 /**
17 * Frontend constructor.
18 *
19 * @since 1.0.0
20 */
21 public function __construct() {
22 // Set time as the version for development mode.
23 if( defined('WP_DEBUG') && WP_DEBUG ){
24 $this->version = time();
25 } else {
26 $this->version = WHOLS_VERSION;
27 }
28
29 // Admin assets hook into action.
30 add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_frontend_assets' ) );
31
32 // Filter the content to add the [whols_registration_form] shortcode to the assigned page
33 add_filter( 'the_content', array( $this, 'filter_the_content' ) );
34
35 }
36
37 /**
38 * Enqueue frontend assets
39 *
40 * @since 1.0.0
41 */
42 public function enqueue_frontend_assets() {
43 // Scripts
44 $suffix = \Automattic\Jetpack\Constants::is_true( 'SCRIPT_DEBUG' ) ? '' : '.min';
45 wp_enqueue_script( 'serializejson', WC()->plugin_url() . '/assets/js/jquery-serializejson/jquery.serializejson' . $suffix . '.js', array( 'jquery' ), '2.8.1' );
46 }
47
48
49 /**
50 * If the content doesn't have the shortcode, add it to the end of the content
51 *
52 * @param content The content of the post.
53 *
54 * @return The content of the page, with the shortcode appended to the end.
55 */
56 public function filter_the_content( $content ){
57 global $post;
58
59 if( $post && $post->ID == whols_get_option('registration_page') && !has_shortcode($content, 'whols_registration_form') ){
60 $shortcode = do_shortcode('[whols_registration_form]');
61 return $content . $shortcode;
62 }
63
64 return $content;
65 }
66 }