plugin_url() . '/assets/' . trim($assets, '/ '); } /** * Return "Vertex Addons for Elementor" Assets Dir Path * * @since 1.0.0 * * @param string $assets * * @return string */ public function assets_path($assets) { return AFEB_ABSPATH . '/assets/' . trim($assets, '/ '); } /** * Get an HTML file using slug and name * * @since 1.0.0 * * @param string $slug * @param string $name * @param bool $include_once */ public function get_template_part($slug = '', $name = 'tpl.php', $include_once = true) { $path = wp_normalize_path("{$slug}/{$name}"); // Only include real template files from inside the current plugin directory. if (preg_match('#^[a-z][a-z0-9+\\-.]*://#i', $path)) { return false; } $base_path = realpath($this->get_path()); $template_path = realpath($path); if (!$base_path || !$template_path || !is_file($template_path) || !is_readable($template_path)) { return false; } $base_path = trailingslashit(wp_normalize_path($base_path)); $template_path = wp_normalize_path($template_path); if (strpos($template_path, $base_path) !== 0) { return false; } if (substr($template_path, -4) !== '.php') { return false; } if ($include_once) return include_once $template_path; return include $template_path; } /** * Redirect to dashboard page after activation * * @since 1.0.0 */ public function redirect_after_activation() { // No need to redirect if (!get_option('_afeb_activation_redirect', false) || wp_doing_ajax()) return; // Delete the option to don't do it again delete_option('_afeb_activation_redirect'); // Redirect to "Vertex Addons for Elementor" Dashboard wp_redirect(admin_url('admin.php?page=' . Menus::MENUS_SLUG)); exit; } /** * Parsing a feed address * * @since 1.0.0 * * @param string $url * @param int $expiration * * @return array */ public function dom_doc($url = '', $expiration = 0) { $feed = get_transient($url); if (!is_array($feed)) { $feed = []; $dom_doc_object = new DOMDocument(); $previous = libxml_use_internal_errors(true); $loaded = $dom_doc_object->load($url); libxml_clear_errors(); libxml_use_internal_errors($previous); if (!$loaded) { return $feed; } foreach ($dom_doc_object->getElementsByTagName('item') as $node) { $item = [ 'title' => $node->getElementsByTagName('title')->item(0)->nodeValue, 'link' => $node->getElementsByTagName('link')->item(0)->nodeValue, 'pubDate' => $node->getElementsByTagName('pubDate')->item(0)->nodeValue, 'guid' => $node->getElementsByTagName('guid')->item(0)->nodeValue, 'description' => $node->getElementsByTagName('description')->item(0)->nodeValue, 'content' => $node->getElementsByTagName('encoded')->item(0)->nodeValue ]; array_push($feed, $item); } if ($expiration > 0) { delete_transient($url); set_transient($url, $feed, $expiration); } } return $feed; } }