| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697 |
- <?php
- /**
- * The public-facing functionality of the plugin.
- *
- * @package QDR_Temporary_Shared_Storage
- * @since 1.0.0
- */
- class QDR_TSS_Public {
- /**
- * The ID of this plugin.
- *
- * @since 1.0.0
- * @access private
- * @var string $plugin_name The ID of this plugin.
- */
- private $plugin_name;
- /**
- * The version of this plugin.
- *
- * @since 1.0.0
- * @access private
- * @var string $version The current version of this plugin.
- */
- private $version;
- /**
- * Initialize the class and set its properties.
- *
- * @since 1.0.0
- * @param string $plugin_name The name of this plugin.
- * @param string $version The version of this plugin.
- */
- public function __construct($plugin_name, $version) {
- $this->plugin_name = $plugin_name;
- $this->version = $version;
- }
- /**
- * Register the stylesheets for the public-facing side of the site.
- *
- * @since 1.0.0
- */
- public function enqueue_styles() {
- // Only load on download page
- if (!is_page('shared-file-download')) {
- return;
- }
-
- wp_enqueue_style(
- $this->plugin_name . '-public',
- plugin_dir_url(dirname(__FILE__)) . 'public/css/public.css',
- array(),
- $this->version,
- 'all'
- );
- }
- /**
- * Register the JavaScript for the public-facing side of the site.
- *
- * @since 1.0.0
- */
- public function enqueue_scripts() {
- // Only load on download page
- if (!is_page('shared-file-download')) {
- return;
- }
-
- wp_enqueue_script(
- $this->plugin_name . '-public',
- plugin_dir_url(dirname(__FILE__)) . 'public/js/public.js',
- array('jquery'),
- $this->version,
- true
- );
- }
- /**
- * Create download page if it doesn't exist.
- *
- * @since 1.0.0
- */
- public function create_download_page() {
- $download_page = get_page_by_path('shared-file-download');
- if (!$download_page) {
- wp_insert_post(array(
- 'post_title' => __('Shared File Download', 'qdr-temporary-shared-storage'),
- 'post_content' => '[qdr_tss_download]',
- 'post_status' => 'publish',
- 'post_type' => 'page',
- 'post_name' => 'shared-file-download'
- ));
- }
- }
- }
|