Inventory_Presser_Plugin::include_scripts_and_styles()

Registers JavaScripts and stylesheets for front-end users and dashboard users. Includes some inline styles and scripts depending on the plugin settings and page request.


Return

(void)


Source

File: inventory-presser.php

				'invp-flexslider',
				plugins_url( "/js/flexslider{$min}.js", INVP_PLUGIN_FILE_PATH ),
				array( 'flexslider' ),
				INVP_PLUGIN_VERSION,
				true
			);
			// Another flexslider spin-up script for the Vehicle Slider widget.
			wp_register_script(
				'invp-slider',
				plugins_url( "/js/widget-slider{$min}.js", INVP_PLUGIN_FILE_PATH ),
				array( 'flexslider' ),
				INVP_PLUGIN_VERSION,
				true
			);

			if ( ! empty( $min ) ) {
				wp_register_style( 'flexslider', plugins_url( "/css/woocommerce-flexslider{$min}.css", INVP_PLUGIN_FILE_PATH ), null, INVP_PLUGIN_VERSION );
			} else {
				wp_register_style( 'flexslider', plugins_url( '/vendor/woocommerce/FlexSlider/flexslider.css', INVP_PLUGIN_FILE_PATH ), null, INVP_PLUGIN_VERSION );
			}
			// Our overrides.
			wp_register_style( 'invp-flexslider', plugins_url( "/css/flexslider{$min}.css", INVP_PLUGIN_FILE_PATH ), array( 'flexslider' ), INVP_PLUGIN_VERSION );

			// Register the iFrameResizer.js script for use by our [invp_iframe] shortcode and Iframe block.
			wp_register_script( 'invp-iframe-resizer', plugins_url( "/js/iframe-resizer/iframeResizer{$min}.js", INVP_PLUGIN_FILE_PATH ), array(), INVP_PLUGIN_VERSION, true );

			/**
			 * Register a stylesheet that will be used by two shortcodes,
			 * [invp_archive_vehicle] and [invp_single_vehicle]
			 */
			wp_register_style(
				'invp-attribute-table',
				plugins_url( "/css/vehicle-attribute-table{$min}.css", INVP_PLUGIN_FILE_PATH ),
				null,
				INVP_PLUGIN_VERSION
			);

			// Register a stylesheet for the archive vehicle shortcode.
			wp_register_style(
				'invp_archive_vehicle',
				plugins_url( "/css/shortcode-archive-vehicle{$min}.css", INVP_PLUGIN_FILE_PATH ),
				null,
				INVP_PLUGIN_VERSION
			);

			// Register a stylesheet for the single vehicle shortcode.
			wp_register_style(
				'invp_single_vehicle',
				plugins_url( "/css/shortcode-single-vehicle{$min}.css", INVP_PLUGIN_FILE_PATH ),
				null,
				INVP_PLUGIN_VERSION
			);

			/**
			 * Make the meta prefix to the front-end (the object name invp is
			 * localized for the admin dashboard in
			 * Inventory_Presser_Admin_Customize_Dashboard)
			 */
			if ( ! is_admin() ) {
				?>
				<script> var invp = 
				<?php
				echo wp_json_encode(
					array(
						'meta_prefix' => INVP::meta_prefix(),
						'is_singular' => is_singular( INVP::POST_TYPE ),
					)
				);
				?>
				; </script>
				<?php
			}
		}

		/**
		 * Adds a link to the settings page near the Activate | Delete links on the
		 * list of plugins on the Plugins page.
		 *
		 * @param  array $links
		 * @return array
		 */
		public function insert_settings_link( $links ) {
			$url     = admin_url(
				sprintf(
					'edit.php?post_type=%s&page=%s',
					INVP::POST_TYPE,
					INVP::OPTION_PAGE
				)
			);
			$links[] = sprintf(
				'<a href="%s">%s</a>',
				$url,
				__( 'Settings', 'inventory-presser' )
			);
			return $links;
		}

		/**
		 * Fires once a vehicle post has been saved.
		 *
		 * @param int     $post_ID Post ID.
		 * @param WP_Post $post    Post object.
		 * @param bool    $update  Whether this is an existing post being updated.
		 */
		public function mark_vehicles_for_sale_during_insertion( $post_ID, $post, $update ) {
			if ( $update ) {
				// Abort, we only want to affect insertions.