| 1 |
<?php |
| 2 |
if ( ! defined( 'ABSPATH' ) ) { |
| 3 |
exit; // Exit if accessed directly |
| 4 |
} |
| 5 |
|
| 6 |
/** |
| 7 |
* |
| 8 |
* |
| 9 |
* @link http://mlsimport.com/ |
| 10 |
* @since 1.0.0 |
| 11 |
* |
| 12 |
* @package Mlsimport |
| 13 |
* @subpackage Mlsimport/public |
| 14 |
*/ |
| 15 |
|
| 16 |
/** |
| 17 |
* @package Mlsimport |
| 18 |
* @subpackage Mlsimport/public |
| 19 |
* @author MlsImport <office@mlsimport.com> |
| 20 |
*/ |
| 21 |
class Mlsimport_Public { |
| 22 |
|
| 23 |
/** |
| 24 |
* The ID of this plugin. |
| 25 |
* |
| 26 |
* @since 1.0.0 |
| 27 |
* @access private |
| 28 |
* @var string $plugin_name The ID of this plugin. |
| 29 |
*/ |
| 30 |
private $plugin_name; |
| 31 |
|
| 32 |
/** |
| 33 |
* The version of this plugin. |
| 34 |
* |
| 35 |
* @since 1.0.0 |
| 36 |
* @access private |
| 37 |
* @var string $version The current version of this plugin. |
| 38 |
*/ |
| 39 |
private $version; |
| 40 |
|
| 41 |
/** |
| 42 |
* Initialize the class and set its properties. |
| 43 |
* |
| 44 |
* @since 1.0.0 |
| 45 |
* @param string $plugin_name The name of the plugin. |
| 46 |
* @param string $version The version of this plugin. |
| 47 |
*/ |
| 48 |
public function __construct( $plugin_name, $version ) { |
| 49 |
|
| 50 |
$this->plugin_name = $plugin_name; |
| 51 |
$this->version = $version; |
| 52 |
} |
| 53 |
|
| 54 |
/** |
| 55 |
* Register the stylesheets for the public-facing side of the site. |
| 56 |
* |
| 57 |
* @since 1.0.0 |
| 58 |
*/ |
| 59 |
public function enqueue_styles() { |
| 60 |
global $mlsimport; |
| 61 |
$theme_enviroment = $mlsimport->get_plugin_data( 'theme_enviroment' ); |
| 62 |
wp_enqueue_style( $this->plugin_name, plugin_dir_url( __FILE__ ) . 'css/mlsimport-public.css', array(), $this->version, 'all' ); |
| 63 |
|
| 64 |
if ( isset( $options['enviroment'] ) ) { |
| 65 |
wp_enqueue_style( $this->plugin_name . strtolower( $theme_enviroment ), plugin_dir_url( __FILE__ ) . 'css/mlsimport-public-' . strtolower( $theme_enviroment ) . '.css', array(), $this->version, 'all' ); |
| 66 |
} |
| 67 |
} |
| 68 |
|
| 69 |
/** |
| 70 |
* Register the JavaScript for the public-facing side of the site. |
| 71 |
* |
| 72 |
* @since 1.0.0 |
| 73 |
*/ |
| 74 |
public function enqueue_scripts() { |
| 75 |
wp_enqueue_script( $this->plugin_name, plugin_dir_url( __FILE__ ) . 'js/mlsimport-public.js', array( 'jquery' ), $this->version, false ); |
| 76 |
} |
| 77 |
|
| 78 |
|
| 79 |
/** |
| 80 |
* ReWrite Image url |
| 81 |
* |
| 82 |
* @since 1.0.0 |
| 83 |
*/ |
| 84 |
/** |
| 85 |
* ReWrite Image url |
| 86 |
* |
| 87 |
* @since 1.0.0 |
| 88 |
*/ |
| 89 |
public function mlsimport_wp_get_attachment_url( $url, $post_id ) { |
| 90 |
|
| 91 |
|
| 92 |
if( intval(get_post_meta($post_id,'is_mlsimport',true)) === 1){ |
| 93 |
|
| 94 |
$explode = explode('/wp-content/uploads/', $url); |
| 95 |
return $explode[1]; |
| 96 |
|
| 97 |
} |
| 98 |
|
| 99 |
return $url; |
| 100 |
} |
| 101 |
} |
| 102 |
|