/** *Load all functions that are needed for both front and backend **/ public function init() { if (isset($_GET['avia_mode'])) { AviaBuilder::$mode = esc_attr($_GET['avia_mode']); } $this->createShortcode(); $this->addActions(); AviaStoragePost::generate_post_type(); //hook into the media uploader. we always need to call this for several hooks to be active new AviaMedia(); //on ajax call load the functions that are usually only loaded on new post and edit post screen if (AviaHelper::is_ajax()) { $this->admin_init(); } }
/** * Helper function that fetches all meta values with a specific key (cross post) * */ private function get_meta_values($key = '_avia_builder_template_%') { global $wpdb; if (empty($key)) { return; } $compare_by = strpos($key, '%') !== false ? "LIKE" : "="; $id = AviaStoragePost::get_custom_post('template_builder_snippets'); $r = $wpdb->get_col($wpdb->prepare("\n SELECT meta_value FROM {$wpdb->postmeta}\n WHERE meta_key {$compare_by} '%s'\n AND post_id = '%s'\n ", $key, $id)); return $r; }