| 1 |  |  | <?php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2 |  |  | /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3 |  |  |  * AH Editor | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5 |  |  |  * @package   Lasso | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6 |  |  |  * @author    Nick Haskins <[email protected]> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7 |  |  |  * @license   GPL-2.0+ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8 |  |  |  * @link      http://aesopinteractive.com | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9 |  |  |  * @copyright 2015-2017 Aesopinteractive  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10 |  |  |  */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11 |  |  | namespace lasso_public_facing; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 12 |  |  | /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 13 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 14 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 15 |  |  |  * @package Lasso | 
            
                                                                                                            
                            
            
                                    
            
            
                | 16 |  |  |  * @author  Nick Haskins <[email protected]> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 17 |  |  |  */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 18 |  |  | class lasso { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 19 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 20 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 21 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 22 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 23 |  |  | 	 * @since    0.0.1 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 24 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 25 |  |  | 	 * @var      string | 
            
                                                                                                            
                            
            
                                    
            
            
                | 26 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 27 |  |  | 	protected $plugin_slug = 'lasso'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 28 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 29 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 30 |  |  | 	 * Instance of this class. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 31 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 32 |  |  | 	 * @since    0.0.1 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 33 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 34 |  |  | 	 * @var      object | 
            
                                                                                                            
                            
            
                                    
            
            
                | 35 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 36 |  |  | 	protected static $instance = null; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 37 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 38 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 39 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 40 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 41 |  |  | 	 * @since     0.0.1 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 42 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 43 |  |  | 	private function __construct() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 44 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 45 |  |  | 		require_once LASSO_DIR.'/public/includes/underscore-templates.php'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 46 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 47 |  |  | 		require_once LASSO_DIR.'/public/includes/editor-modules.php'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 48 |  |  | 		require_once LASSO_DIR.'/public/includes/helpers.php'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 49 |  |  | 		require_once LASSO_DIR.'/public/includes/editor-modules--gallery.php'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 50 |  |  | 		require_once LASSO_DIR.'/public/includes/components.php'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 51 |  |  | 		require_once LASSO_DIR.'/public/includes/option-engine.php'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 52 |  |  | 		require_once LASSO_DIR.'/public/includes/wrap-shortcodes.php'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 53 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 54 |  |  | 		// Activate plugin when new blog is added | 
            
                                                                                                            
                            
            
                                    
            
            
                | 55 |  |  | 		add_action( 'wpmu_new_blog', array( $this, 'activate_new_site' ) ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 56 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 57 |  |  | 		// Load plugin text domain | 
            
                                                                                                            
                            
            
                                    
            
            
                | 58 |  |  | 		add_action( 'init', array( $this, 'load_plugin_textdomain' ) ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 59 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 60 |  |  | 		add_action( 'wp_ajax_get_aesop_component',     array( $this, 'get_aesop_component' ) ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 61 |  |  | 		add_action( 'wp_ajax_editus_do_shortcode',     array( $this, 'editus_do_shortcode' ) ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 62 |  |  | 		add_action( 'wp_ajax_editus_lock_post',     array( $this, 'editus_lock_post' ) ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 63 |  |  | 		add_action( 'wp_ajax_editus_hide_tour',     array( $this, 'editus_hide_tour' ) ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 64 |  |  | 		add_action( 'wp_ajax_editus_set_post_setting',     array( $this, 'editus_set_post_setting' ) ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 65 |  |  | 		add_action( 'wp_ajax_editus_get_ase_options',     array( $this, 'get_ase_options' ) ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 66 |  |  | 		add_action( 'wp_ajax_editus_delete_post',     array( $this, 'delete_post' ) ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 67 |  |  | 		add_action( 'wp_ajax_editus_featured_img',     array( $this, 'set_featured_img' ) ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 68 |  |  | 		add_action( 'wp_ajax_editus_del_featured_img',     array( $this, 'del_featured_img' ) ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 69 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 70 |  |  | 		// enable saving custom fields through REST API | 
            
                                                                                                            
                            
            
                                    
            
            
                | 71 |  |  | 		self::enable_metasave('post'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 72 |  |  | 		self::enable_metasave('page'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 73 |  |  | 		//enqueue assets | 
            
                                                                                                            
                            
            
                                    
            
            
                | 74 |  |  | 		new assets(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 75 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 76 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 77 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 78 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 79 |  |  | 	 * Return the plugin slug. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 80 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 81 |  |  | 	 * @since    0.0.1 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 82 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 83 |  |  | 	 * @return    Plugin slug variable. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 84 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 85 |  |  | 	public function get_plugin_slug() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 86 |  |  | 		return $this->plugin_slug; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 87 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 88 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 89 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 90 |  |  | 	 * Return an instance of this class. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 91 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 92 |  |  | 	 * @since     0.0.1 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 93 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 94 |  |  | 	 * @return    object    A single instance of this class. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 95 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 96 |  |  | 	public static function get_instance() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 97 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 98 |  |  | 		// If the single instance hasn't been set, set it now. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 99 |  |  | 		if ( null == self::$instance ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 100 |  |  | 			self::$instance = new self; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 101 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 102 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 103 |  |  | 		return self::$instance; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 104 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 105 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 106 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 107 |  |  | 	 * Fired when the plugin is activated. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 108 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 109 |  |  | 	 * @since    0.0.1 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 110 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 111 |  |  | 	 * @param boolean $network_wide True if WPMU superadmin uses | 
            
                                                                                                            
                            
            
                                    
            
            
                | 112 |  |  | 	 *                                       "Network Activate" action, false if | 
            
                                                                                                            
                            
            
                                    
            
            
                | 113 |  |  | 	 *                                       WPMU is disabled or plugin is | 
            
                                                                                                            
                            
            
                                    
            
            
                | 114 |  |  | 	 *                                       activated on an individual blog. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 115 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                                                    
                                                                                                        
            
            
                | 116 |  | View Code Duplication | 	public static function activate( $network_wide ) { | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 117 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 118 |  |  | 		if ( function_exists( 'is_multisite' ) && is_multisite() ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 119 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 120 |  |  | 			if ( $network_wide  ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 121 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 122 |  |  | 				// Get all blog ids | 
            
                                                                                                            
                            
            
                                    
            
            
                | 123 |  |  | 				$blog_ids = self::get_blog_ids(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 124 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 125 |  |  | 				foreach ( $blog_ids as $blog_id ) { | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 126 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 127 |  |  | 					switch_to_blog( $blog_id ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 128 |  |  | 					self::single_activate(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 129 |  |  | 				} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 130 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 131 |  |  | 				restore_current_blog(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 132 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 133 |  |  | 			} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 134 |  |  | 				self::single_activate(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 135 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 136 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 137 |  |  | 		} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 138 |  |  | 			self::single_activate(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 139 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 140 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 141 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 142 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 143 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 144 |  |  | 	 * Fired when the plugin is deactivated. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 145 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 146 |  |  | 	 * @since    0.0.1 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 147 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 148 |  |  | 	 * @param boolean $network_wide True if WPMU superadmin uses | 
            
                                                                                                            
                            
            
                                    
            
            
                | 149 |  |  | 	 *                                       "Network Deactivate" action, false if | 
            
                                                                                                            
                            
            
                                    
            
            
                | 150 |  |  | 	 *                                       WPMU is disabled or plugin is | 
            
                                                                                                            
                            
            
                                    
            
            
                | 151 |  |  | 	 *                                       deactivated on an individual blog. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 152 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                                                    
                                                                                                        
            
            
                | 153 |  | View Code Duplication | 	public static function deactivate( $network_wide ) { | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 154 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 155 |  |  | 		if ( function_exists( 'is_multisite' ) && is_multisite() ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 156 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 157 |  |  | 			if ( $network_wide ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 158 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 159 |  |  | 				// Get all blog ids | 
            
                                                                                                            
                            
            
                                    
            
            
                | 160 |  |  | 				$blog_ids = self::get_blog_ids(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 161 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 162 |  |  | 				foreach ( $blog_ids as $blog_id ) { | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 163 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 164 |  |  | 					switch_to_blog( $blog_id ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 165 |  |  | 					self::single_deactivate(); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 166 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 167 |  |  | 				} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 168 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 169 |  |  | 				restore_current_blog(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 170 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 171 |  |  | 			} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 172 |  |  | 				self::single_deactivate(); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 173 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 174 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 175 |  |  | 		} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 176 |  |  | 			self::single_deactivate(); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 177 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 178 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 179 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 180 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 181 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 182 |  |  | 	 * Fired when a new site is activated with a WPMU environment. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 183 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 184 |  |  | 	 * @since    0.0.1 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 185 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 186 |  |  | 	 * @param int     $blog_id ID of the new blog. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 187 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 188 |  |  | 	public function activate_new_site( $blog_id ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 189 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 190 |  |  | 		if ( 1 !== did_action( 'wpmu_new_blog' ) ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 191 |  |  | 			return; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 192 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 193 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 194 |  |  | 		switch_to_blog( $blog_id ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 195 |  |  | 		self::single_activate(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 196 |  |  | 		restore_current_blog(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 197 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 198 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 199 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 200 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 201 |  |  | 	 * Get all blog ids of blogs in the current network that are: | 
            
                                                                                                            
                            
            
                                    
            
            
                | 202 |  |  | 	 * - not archived | 
            
                                                                                                            
                            
            
                                    
            
            
                | 203 |  |  | 	 * - not spam | 
            
                                                                                                            
                            
            
                                    
            
            
                | 204 |  |  | 	 * - not deleted | 
            
                                                                                                            
                            
            
                                    
            
            
                | 205 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 206 |  |  | 	 * @since    0.0.1 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 207 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 208 |  |  | 	 * @return   array|false    The blog ids, false if no matches. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 209 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 210 |  |  | 	private static function get_blog_ids() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 211 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 212 |  |  | 		global $wpdb; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 213 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 214 |  |  | 		// get an array of blog ids | 
            
                                                                                                            
                            
            
                                    
            
            
                | 215 |  |  | 		$sql = "SELECT blog_id FROM $wpdb->blogs | 
            
                                                                                                            
                            
            
                                    
            
            
                | 216 |  |  | 			WHERE archived = '0' AND spam = '0' | 
            
                                                                                                            
                            
            
                                    
            
            
                | 217 |  |  | 			AND deleted = '0'"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 218 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 219 |  |  | 		return $wpdb->get_col( $sql ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 220 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 221 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 222 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 223 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 224 |  |  | 	 * Fired for each blog when the plugin is activated. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 225 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 226 |  |  | 	 * @since    0.0.1 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 227 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 228 |  |  | 	private static function single_activate() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 229 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 230 |  |  | 		$curr_version = get_option( 'lasso_version' ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 231 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 232 |  |  | 		// update upgraded from | 
            
                                                                                                            
                            
            
                                    
            
            
                | 233 |  |  | 		if ( $curr_version ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 234 |  |  | 			update_option( 'lasso_updated_from', $curr_version ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 235 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 236 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 237 |  |  | 		// update lasso version option | 
            
                                                                                                            
                            
            
                                    
            
            
                | 238 |  |  | 		update_option( 'lasso_version', LASSO_VERSION ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 239 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 240 |  |  | 		// set transietn for activation welcome | 
            
                                                                                                            
                            
            
                                    
            
            
                | 241 |  |  | 		set_transient( '_lasso_welcome_redirect', true, 30 ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 242 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 243 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 244 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 245 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 246 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 247 |  |  | 	 * Fired for each blog when the plugin is deactivated. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 248 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 249 |  |  | 	 * @since    0.0.1 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 250 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 251 |  |  | 	private static function single_deactivate() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 252 |  |  | 		// @TODO: Define deactivation functionality here | 
            
                                                                                                            
                            
            
                                    
            
            
                | 253 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 254 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 255 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 256 |  |  | 	 * Load the plugin text domain for translation. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 257 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 258 |  |  | 	 * @since    1.0.0 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 259 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 260 |  |  | 	public function load_plugin_textdomain() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 261 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 262 |  |  | 		$domain = $this->plugin_slug; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 263 |  |  | 		$locale = apply_filters( 'plugin_locale', get_locale(), $domain ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 264 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 265 |  |  | 		$out = load_textdomain( $domain, trailingslashit( LASSO_DIR ). 'languages/' . $domain . '-' . $locale . '.mo' ); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 266 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 267 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 268 |  |  |     // new ajax function to lock post for editing | 
            
                                                                                                            
                            
            
                                    
            
            
                | 269 |  |  | 	public function editus_lock_post() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 270 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 271 |  |  | 		$post_id= $_POST["postid"]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 272 |  |  | 		$locked = wp_check_post_lock($post_id); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 273 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 274 |  |  | 		if (!$locked) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 275 |  |  | 		    wp_set_post_lock($post_id); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 276 |  |  | 			echo "true"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 277 |  |  | 		} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 278 |  |  | 			$user_info = get_userdata($locked); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 279 |  |  | 			echo "Post opened by ".$user_info->first_name .  " " . $user_info->last_name; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 280 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 281 |  |  | 		exit; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 282 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 283 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 284 |  |  | 	// new ajax function to update tour setting | 
            
                                                                                                            
                            
            
                                    
            
            
                | 285 |  |  | 	public function editus_hide_tour() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 286 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 287 |  |  | 		$user_id = get_current_user_ID(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 288 |  |  | 				 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 289 |  |  | 		update_user_meta( $user_id, 'lasso_hide_tour', true ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 290 |  |  | 		exit; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 291 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 292 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 293 |  |  | 	public function editus_set_post_setting() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 294 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 295 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 296 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 297 |  |  | 		$data = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 298 |  |  | 		parse_str($_POST['data'], $data); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 299 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 300 |  |  | 		if (!wp_verify_nonce( $data[ 'nonce' ], 'lasso-update-post-settings' )) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 301 |  |  | 			wp_send_json_error(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 302 |  |  | 			exit; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 303 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 304 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 305 |  |  | 		$status = isset( $data['status'] ) ? $data['status'] : false; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 306 |  |  | 		$postid = isset( $data['postid'] ) ? $data['postid'] : false; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 307 |  |  | 		$slug   = isset( $data['story_slug'] ) ? $data['story_slug'] : false; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 308 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 309 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 310 |  |  | 		$args = array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 311 |  |  | 			'ID'   			=> (int) $postid, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 312 |  |  | 			'post_name'  	=> $slug, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 313 |  |  | 			'post_status' 	=> $status | 
            
                                                                                                            
                            
            
                                    
            
            
                | 314 |  |  | 		); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 315 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 316 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 317 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 318 |  |  | 		wp_update_post( apply_filters( 'lasso_object_status_update_args', $args ) ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 319 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 320 |  |  | 		// update categories | 
            
                                                                                                            
                            
            
                                    
            
            
                | 321 |  |  | 		$cats  = isset( $data['story_cats'] ) ? $data['story_cats'] : false; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 322 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 323 |  |  | 		self::set_post_terms( $postid, $cats, 'category' ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 324 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 325 |  |  | 		// update tags | 
            
                                                                                                            
                            
            
                                    
            
            
                | 326 |  |  | 		$tags = isset( $data['story_tags'] ) ? $data['story_tags'] : false; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 327 |  |  | 		self::set_post_terms( $postid, $tags, 'post_tag' ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 328 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 329 |  |  | 		//update date | 
            
                                                                                                            
                            
            
                                    
            
            
                | 330 |  |  | 		$date  = isset( $data['post_date'] ) ? $data['post_date'] : false; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 331 |  |  | 		self::set_date( $postid, $date ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 332 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 333 |  |  | 		do_action( 'lasso_post_updated', $postid, $slug, $status, get_current_user_ID() ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 334 |  |  | 		$response= array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 335 |  |  | 			'link'   => get_permalink($postid). (($status=='publish') ? '' : '&preview=true') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 336 |  |  | 		); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 337 |  |  | 		wp_send_json_success($response); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 338 |  |  | 		exit; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 339 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 340 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 341 |  |  | 	public static function enable_metasave($type) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 342 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 343 |  |  | 		register_rest_field( $type, 'metadata', array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 344 |  |  | 			'get_callback' => function ( $data ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 345 |  |  | 				return get_post_meta( $data['id']);//, '', '' ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 346 |  |  | 			},  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 347 |  |  | 			'update_callback' => function( $data, $post ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 348 |  |  | 				foreach ($data as $key => $value) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 349 |  |  | 					update_post_meta($post->ID, $key, $value); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 350 |  |  | 				} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 351 |  |  | 				return true; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 352 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 353 |  |  | 		)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 354 |  |  | 	} | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 355 |  |  | 	 | 
            
                                                                        
                            
            
                                    
            
            
                | 356 |  |  | 	public function editus_do_shortcode() | 
            
                                                                        
                            
            
                                    
            
            
                | 357 |  |  | 	{ | 
            
                                                                        
                            
            
                                    
            
            
                | 358 |  |  | 		 | 
            
                                                                        
                            
            
                                    
            
            
                | 359 |  |  | 		$code= $_POST["code"]; | 
            
                                                                        
                            
            
                                    
            
            
                | 360 |  |  | 		$code = str_replace('\"', '"', $code); | 
            
                                                                        
                            
            
                                    
            
            
                | 361 |  |  | 		 | 
            
                                                                        
                            
            
                                    
            
            
                | 362 |  |  | 		$code_wrapped = lasso_wrap_shortcodes( $code); | 
            
                                                                        
                            
            
                                    
            
            
                | 363 |  |  | 		$out =  do_shortcode($code); | 
            
                                                                        
                            
            
                                    
            
            
                | 364 |  |  | 		if ($out != '') { | 
            
                                                                        
                            
            
                                    
            
            
                | 365 |  |  | 			$out =  do_shortcode($code_wrapped); | 
            
                                                                        
                            
            
                                    
            
            
                | 366 |  |  | 			echo $out; | 
            
                                                                        
                            
            
                                    
            
            
                | 367 |  |  | 			exit; | 
            
                                                                        
                            
            
                                    
            
            
                | 368 |  |  | 		} | 
            
                                                                        
                            
            
                                    
            
            
                | 369 |  |  | 		 | 
            
                                                                        
                            
            
                                    
            
            
                | 370 |  |  | 		// do_shortcode didn't work. Try again using wp_embed | 
            
                                                                        
                            
            
                                    
            
            
                | 371 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 372 |  |  | 		/** @var \WP_Embed $wp_embed */ | 
            
                                                                        
                            
            
                                    
            
            
                | 373 |  |  | 		global $wp_embed; | 
            
                                                                        
                            
            
                                    
            
            
                | 374 |  |  | 		$wp_embed->post_ID = $_POST["ID"]; | 
            
                                                                        
                            
            
                                    
            
            
                | 375 |  |  | 		$out =$wp_embed->run_shortcode( $code_wrapped ); | 
            
                                                                        
                            
            
                                    
            
            
                | 376 |  |  | 		 | 
            
                                                                        
                            
            
                                    
            
            
                | 377 |  |  | 		echo $out; | 
            
                                                                        
                            
            
                                    
            
            
                | 378 |  |  | 		exit; | 
            
                                                                        
                            
            
                                    
            
            
                | 379 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 380 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 381 |  |  | 	public function get_aesop_component() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 382 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 383 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 384 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 385 |  |  | 		$code= $_POST["code"]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 386 |  |  | 		$atts = array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 387 |  |  | 		 ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 388 |  |  | 		foreach ($_POST as $key => $value) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 389 |  |  | 			if ($key !="code" && $key !="action") { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 390 |  |  | 			    //$shortcode = $shortcode.$key.'="'.$value.'" '; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 391 |  |  | 				$atts[$key] = $value; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 392 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 393 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 394 |  |  | 		if ($code == "aesop_video") { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 395 |  |  | 		    require_once( ABSPATH . '/wp-content/plugins/aesop-story-engine/public/includes/components/component-video.php'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 396 |  |  | 		    echo aesop_video_shortcode($atts); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 397 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 398 |  |  | 		else if ($code == "aesop_image") { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 399 |  |  | 		    require_once( ABSPATH . '/wp-content/plugins/aesop-story-engine/public/includes/components/component-image.php'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 400 |  |  | 		    echo aesop_image_shortcode($atts); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 401 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 402 |  |  | 		else if ($code == "aesop_quote") { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 403 |  |  | 		    require_once( ABSPATH . '/wp-content/plugins/aesop-story-engine/public/includes/components/component-quote.php'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 404 |  |  | 		    echo aesop_quote_shortcode($atts); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 405 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 406 |  |  | 		else if ($code == "aesop_parallax") { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 407 |  |  | 		    require_once( ABSPATH . '/wp-content/plugins/aesop-story-engine/public/includes/components/component-parallax.php'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 408 |  |  | 		    echo aesop_parallax_shortcode($atts); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 409 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 410 |  |  | 		else if ($code == "aesop_character") { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 411 |  |  | 		    require_once( ABSPATH . '/wp-content/plugins/aesop-story-engine/public/includes/components/component-character.php'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 412 |  |  | 		    echo aesop_character_shortcode($atts); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 413 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 414 |  |  | 		else if ($code == "aesop_collection") { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 415 |  |  | 		    require_once( ABSPATH . '/wp-content/plugins/aesop-story-engine/public/includes/components/component-collections.php'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 416 |  |  | 		    echo aesop_collection_shortcode($atts); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 417 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 418 |  |  | 		else if ($code == "aesop_chapter") { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 419 |  |  | 		    require_once( ABSPATH . '/wp-content/plugins/aesop-story-engine/public/includes/components/component-heading.php'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 420 |  |  | 		    echo aesop_chapter_shortcode($atts); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 421 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 422 |  |  | 		else if ($code == "aesop_content") { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 423 |  |  | 		    require_once( ABSPATH . '/wp-content/plugins/aesop-story-engine/public/includes/components/component-cbox.php'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 424 |  |  | 		    echo aesop_content_shortcode($atts, $atts['content_data']); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 425 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 426 |  |  | 		else if ($code == "aesop_gallery") { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 427 |  |  | 		    require_once( ABSPATH . '/wp-content/plugins/aesop-story-engine/public/includes/components/component-gallery.php'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 428 |  |  | 		    echo do_shortcode( '[aesop_gallery id="'.$atts["id"].'"]'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 429 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 430 |  |  | 		else if ($code == "aesop_audio") { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 431 |  |  | 		    require_once( ABSPATH . '/wp-content/plugins/aesop-story-engine/public/includes/components/component-audio.php'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 432 |  |  | 		    echo aesop_audio_shortcode($atts); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 433 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 434 |  |  | 		else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 435 |  |  | 			$code = '['.$code.' '; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 436 |  |  | 			foreach ($atts as $key => $value) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 437 |  |  | 			    $code = ''.$key.'="'.$value.'" '; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 438 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 439 |  |  | 			$code = $code.']'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 440 |  |  | 			echo do_shortcode($code); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 441 |  |  | 		    //require_once( ABSPATH . '/wp-content/plugins/aesop-events/public/includes/shortcode.php'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 442 |  |  | 		    //echo aesop_audio_shortcode($atts); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 443 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 444 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 445 |  |  | 		exit;  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 446 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 447 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 448 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 449 |  |  | 	public function get_ase_options() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 450 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 451 |  |  | 		$blob = lasso_editor_options_blob(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 452 |  |  | 		$code= $_POST["component"]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 453 |  |  | 		echo $blob[$code]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 454 |  |  | 		exit;  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 455 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 456 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 457 |  |  | 	public function delete_post( ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 458 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 459 |  |  | 		$postid = isset( $_POST['postid'] ) ? $_POST['postid'] : false; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 460 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 461 |  |  | 		// bail out if teh current user can't publish posts | 
            
                                                                                                            
                            
            
                                    
            
            
                | 462 |  |  | 		if ( !lasso_user_can( 'delete_post', $postid ) ) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 463 |  |  | 			return; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 464 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 465 |  |  | 		if (!wp_verify_nonce( $_POST[ 'nonce' ], 'lasso_delete_post' )) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 466 |  |  | 			wp_send_json_error(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 467 |  |  | 			exit; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 468 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 469 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 470 |  |  | 		$args = array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 471 |  |  | 			'ID'   			=> (int) $postid, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 472 |  |  | 			'post_status' 	=> 'trash' | 
            
                                                                                                            
                            
            
                                    
            
            
                | 473 |  |  | 		); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 474 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 475 |  |  | 		wp_update_post( apply_filters( 'lasso_object_deleted_args', $args ) ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 476 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 477 |  |  | 		do_action( 'lasso_object_deleted', $postid, get_current_user_ID() ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 478 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 479 |  |  | 		exit; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 480 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 481 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 482 |  |  | 	public function set_featured_img( ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 483 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 484 |  |  | 		$postid  	= isset( $_POST['postid'] ) ? $_POST['postid'] : false; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 485 |  |  | 		$image_id  	= isset( $_POST['image_id'] ) ? absint( $_POST['image_id'] ) : false; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 486 |  |  | 		if (!wp_verify_nonce( $_POST[ 'nonce' ], 'lasso_gallery' )) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 487 |  |  | 			wp_send_json_error(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 488 |  |  | 			exit; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 489 |  |  | 		}	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 490 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 491 |  |  | 		set_post_thumbnail( $postid, $image_id ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 492 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 493 |  |  | 		do_action( 'lasso_featured_image_set', $postid, $image_id, get_current_user_ID() ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 494 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 495 |  |  | 		exit; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 496 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 497 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 498 |  |  | 	public function del_featured_img( ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 499 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 500 |  |  | 		$postid  = isset( $_POST['postid'] ) ? $_POST['postid'] : false; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 501 |  |  | 		if (!wp_verify_nonce( $_POST[ 'nonce' ], 'lasso_gallery' )) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 502 |  |  | 			wp_send_json_error(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 503 |  |  | 			exit; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 504 |  |  | 		}	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 505 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 506 |  |  | 		delete_post_thumbnail( $postid ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 507 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 508 |  |  | 		do_action( 'lasso_featured_image_deleted', $postid, get_current_user_ID() ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 509 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 510 |  |  | 		exit; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 511 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 512 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 513 |  |  | 	/*public function revision_get( ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 514 |  |  | 		$args = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 515 |  |  | 		if ( isset( $_POST[ 'limit' ] ) ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 516 |  |  | 			$args[ 'posts_per_page' ] = $data[ 'limit' ]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 517 |  |  | 		}else{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 518 |  |  | 			$args[ 'posts_per_page' ] = 6; // we start at revision 0 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 519 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 520 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 521 |  |  | 		$revisions = wp_get_post_revisions( $_POST[ 'postid' ], $args  ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 522 |  |  | 		if ( is_array( $revisions )  && ! empty( $revisions )  ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 523 |  |  | 			self::set_revisions( $data[ 'postid' ], $revisions ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 524 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 525 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 526 |  |  | 		return self::$revisions; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 527 |  |  | 	}*/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 528 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 529 |  |  | 	public function set_post_terms( $postid, $value, $taxonomy ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 530 |  |  | 		if( $value ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 531 |  |  | 			$value = explode( ',', $value ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 532 |  |  | 			$allow_new_category = lasso_editor_get_option( 'allow_new_category', 'lasso_editor' ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 533 |  |  | 			 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 534 |  |  | 			if ($taxonomy =='category') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 535 |  |  |                 // convert from names to category ids | 
            
                                                                                                            
                            
            
                                    
            
            
                | 536 |  |  | 				$cats = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 537 |  |  | 				foreach ($value as $cat) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 538 |  |  | 					$cat_id = get_cat_ID($cat); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 539 |  |  | 					if ($cat_id !=0) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 540 |  |  | 						$cats [] = $cat_id; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 541 |  |  | 					} else if ($allow_new_category) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 542 |  |  | 					    $cats [] = wp_create_category($cat); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 543 |  |  | 					} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 544 |  |  | 				} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 545 |  |  | 				$value = $cats; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 546 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 547 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 548 |  |  | 			$result = wp_set_object_terms( $postid, $value, $taxonomy ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 549 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 550 |  |  | 		else  { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 551 |  |  | 			//remove all terms from post | 
            
                                                                                                            
                            
            
                                    
            
            
                | 552 |  |  | 			$result = wp_set_object_terms( $postid, null, $taxonomy ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 553 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 554 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 555 |  |  | 		if ( ! is_wp_error( $result ) ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 556 |  |  | 			return true; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 557 |  |  | 		}else{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 558 |  |  | 			return false; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 559 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 560 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 561 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 562 |  |  | 	function getEnglishMonthName($foreignMonthName){ | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 563 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 564 |  |  | 		  setlocale(LC_ALL, 'en_US'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 565 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 566 |  |  | 		  $month_numbers = range(1,12); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 567 |  |  |  | 
            
                                                                                                            
                            
            
                                                                    
                                                                                                        
            
            
                | 568 |  | View Code Duplication | 		  foreach($month_numbers as $month) | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 569 |  |  | 			$english_months[] = strftime('%B',mktime(0,0,0,$month,1,2011)); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 570 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 571 |  |  | 		  setlocale(LC_ALL, get_locale()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 572 |  |  |  | 
            
                                                                                                            
                            
            
                                                                    
                                                                                                        
            
            
                | 573 |  | View Code Duplication | 		  foreach($month_numbers as $month) | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 574 |  |  | 			$foreign_months[] = strftime('%B',mktime(0,0,0,$month,1,2011)); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 575 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 576 |  |  | 		  return str_replace($foreign_months, $english_months, $foreignMonthName); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 577 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 578 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 579 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 580 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 581 |  |  | 	public function set_date( $postid, $value) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 582 |  |  | 		if( $value ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 583 |  |  | 			$value = self::getEnglishMonthName($value)." ".date("H:i:s", current_time( 'timestamp', 1 )); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 584 |  |  |             wp_update_post( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 585 |  |  | 				array ( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 586 |  |  | 					'ID'            => $postid, // ID of the post to update | 
            
                                                                                                            
                            
            
                                    
            
            
                | 587 |  |  | 					'post_date'     => date( 'Y-m-d H:i:s',  strtotime($value) ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 588 |  |  | 					'post_date_gmt'     => gmdate( 'Y-m-d H:i:s',  strtotime($value) ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 589 |  |  | 				) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 590 |  |  | 			); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 591 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 592 |  |  | 	} | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 593 |  |  | } | 
            
                                                        
            
                                    
            
            
                | 594 |  |  |  | 
            
                        
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.