function cs_get_path_locate()
 {
     if (!function_exists('get_plugins') || !function_exists('is_plugin_active')) {
         include_once ABSPATH . 'wp-admin/includes/plugin.php';
     }
     foreach (get_plugins() as $key => $value) {
         if (strpos($key, 'cs-framework.php') !== false) {
             if (is_plugin_active($key)) {
                 $basename = '/' . str_replace('/cs-framework.php', '', $key);
                 $dir = WP_PLUGIN_DIR . $basename;
                 $uri = WP_PLUGIN_URL . $basename;
             }
         }
     }
     if (!isset($basename)) {
         $dirname = wp_normalize_path(dirname(__FILE__));
         $plugin_dir = wp_normalize_path(WP_PLUGIN_DIR);
         $located_plugin = preg_match('#' . $plugin_dir . '#', $dirname) ? true : false;
         $directory = $located_plugin ? $plugin_dir : get_template_directory();
         $directory_uri = $located_plugin ? WP_PLUGIN_URL : get_template_directory_uri();
         $basename = str_replace(wp_normalize_path($directory), '', $dirname);
         $dir = $directory . $basename;
         $uri = $directory_uri . $basename;
     }
     return apply_filters('cs_get_path_locate', array('basename' => wp_normalize_path($basename), 'dir' => wp_normalize_path($dir), 'uri' => $uri));
 }
예제 #2
0
 private function get_from_api()
 {
     // The path to the PHP array file containing the fonts.
     // This is auto-generated by running "grunt googlefonts"
     $path = wp_normalize_path(dirname(__FILE__) . '/googlefonts-array.php');
     // Get the contents of the file
     $fonts_array = (include $path);
     $final_fonts = array();
     if (isset($fonts_array['items'])) {
         $all_variants = array();
         foreach ($fonts_array['items'] as $font) {
             // If font-family is not set then skip this item.
             if (!isset($font['family'])) {
                 continue;
             }
             $final_fonts[$font['family']] = array('variants' => array(), 'subsets' => array());
             if (isset($font['variants']) && is_array($font['variants'])) {
                 foreach ($font['variants'] as $variant) {
                     $final_fonts[$font['family']]['variants'][] = $this->convert_font_variants($variant);
                 }
             }
             if (isset($font['subsets']) && is_array($font['subsets'])) {
                 foreach ($font['subsets'] as $subset) {
                     $final_fonts[$font['family']]['subsets'][] = $this->convert_font_subsets($subset);
                 }
             }
         }
     }
     return $final_fonts;
 }
예제 #3
0
 /**
  * Get shortcode output
  *
  * @param string      $shortcode Shortcode tag
  * @param array       $atts      Shortcode attributes
  * @param string|null $content   Shortcode content
  *
  * @return string Shortcode HTML
  */
 private function render($shortcode, $atts = array(), $content = null)
 {
     /**
      * @var string $html Shortcode html output
      */
     $html = '';
     /**
      * @var string Absolute path to default shortcodes templates directory
      */
     $default = wp_normalize_path(APPICA_CORE_ROOT . '/templates/shortcodes');
     /**
      * Filter the absolute path to shortcodes folder.
      * Allow to override any shortcode templates.
      *
      * @since 1.0.0
      *
      * @param string $default Default absolute path to shortcode templates folder
      */
     $path = apply_filters('appica_shortcodes_templates_path', $default);
     $path = untrailingslashit($path);
     // finally, path to shortcode template
     $template = "{$path}/{$shortcode}.php";
     // if user template doesn't exists - use default one
     if (!is_readable($template)) {
         $template = "{$default}/{$shortcode}.php";
     }
     if (is_readable($template)) {
         ob_start();
         require $template;
         $html = ob_get_contents();
         ob_end_clean();
     }
     return $html;
 }
예제 #4
0
 /**
  * The Kirki class autoloader.
  * Finds the path to a class that we're requiring and includes the file.
  */
 function kirki_autoload_classes($class_name)
 {
     $paths = array();
     if (0 === stripos($class_name, 'Kirki')) {
         $path = dirname(__FILE__) . '/includes/';
         $filename = 'class-' . strtolower(str_replace('_', '-', $class_name)) . '.php';
         $paths[] = $path . $filename;
         $paths[] = dirname(__FILE__) . '/includes/lib/' . $filename;
         $substr = str_replace('Kirki_', '', $class_name);
         $exploded = explode('_', $substr);
         $levels = count($exploded);
         $previous_path = '';
         for ($i = 0; $i < $levels; $i++) {
             $paths[] = $path . $previous_path . strtolower($exploded[$i]) . '/' . $filename;
             $previous_path .= strtolower($exploded[$i]) . '/';
         }
         foreach ($paths as $path) {
             $path = wp_normalize_path($path);
             if (file_exists($path)) {
                 include_once $path;
                 return;
             }
         }
     }
 }
예제 #5
0
 /**
  * Properly set the Kirki URL for assets.
  * Determines if Kirki is installed as a plugin, in a child theme, or a parent theme
  * and then does some calculations to get the proper URL for its CSS & JS assets.
  */
 public function set_url()
 {
     // The path of the Kirki's parent-folder.
     $path = wp_normalize_path(dirname(Kirki::$path));
     // Get parent-theme path.
     $parent_theme_path = get_template_directory();
     $parent_theme_path = wp_normalize_path($parent_theme_path);
     // Get child-theme path.
     $child_theme_path = get_stylesheet_directory_uri();
     $child_theme_path = wp_normalize_path($child_theme_path);
     Kirki::$url = plugin_dir_url(dirname(__FILE__) . 'kirki.php');
     // Is Kirki included in a parent theme?
     if (false !== strpos(Kirki::$path, $parent_theme_path)) {
         Kirki::$url = get_template_directory_uri() . str_replace($parent_theme_path, '', Kirki::$path);
     }
     // Is there a child-theme?
     if ($child_theme_path !== $parent_theme_path) {
         // Is Kirki included in a child theme?
         if (false !== strpos(Kirki::$path, $child_theme_path)) {
             Kirki::$url = get_template_directory_uri() . str_replace($child_theme_path, '', Kirki::$path);
         }
     }
     // Apply the kirki/config filter.
     $config = apply_filters('kirki/config', array());
     if (isset($config['url_path'])) {
         Kirki::$url = esc_url_raw($config['url_path']);
     }
 }
예제 #6
0
파일: init.php 프로젝트: MatRouault/Beans
/**
 * Define constants.
 *
 * @ignore
 */
function beans_define_constants()
{
    // Define version.
    define('BEANS_VERSION', '1.2.4');
    // Define paths.
    define('BEANS_THEME_PATH', wp_normalize_path(trailingslashit(get_template_directory())));
    define('BEANS_PATH', BEANS_THEME_PATH . 'lib/');
    define('BEANS_ASSETS_PATH', BEANS_PATH . 'assets/');
    define('BEANS_LANGUAGES_PATH', BEANS_PATH . 'languages/');
    define('BEANS_RENDER_PATH', BEANS_PATH . 'render/');
    define('BEANS_TEMPLATES_PATH', BEANS_PATH . 'templates/');
    define('BEANS_STRUCTURE_PATH', BEANS_TEMPLATES_PATH . 'structure/');
    define('BEANS_FRAGMENTS_PATH', BEANS_TEMPLATES_PATH . 'fragments/');
    // Define urls.
    define('BEANS_THEME_URL', trailingslashit(get_template_directory_uri()));
    define('BEANS_URL', BEANS_THEME_URL . 'lib/');
    define('BEANS_ASSETS_URL', BEANS_URL . 'assets/');
    define('BEANS_LESS_URL', BEANS_ASSETS_URL . 'less/');
    define('BEANS_JS_URL', BEANS_ASSETS_URL . 'js/');
    define('BEANS_IMAGE_URL', BEANS_ASSETS_URL . 'images/');
    // Define admin paths.
    define('BEANS_ADMIN_PATH', BEANS_PATH . 'admin/');
    // Define admin url */
    define('BEANS_ADMIN_URL', BEANS_URL . 'admin/');
    define('BEANS_ADMIN_ASSETS_URL', BEANS_ADMIN_URL . 'assets/');
    define('BEANS_ADMIN_JS_URL', BEANS_ADMIN_ASSETS_URL . 'js/');
}
예제 #7
0
 /**
  * Generate the data from the PHPDoc markup.
  *
  * @param string $path   Directory or file to scan for PHPDoc
  * @param string $format What format the data is returned in: [json|array].
  *
  * @return string|array
  */
 protected function _get_phpdoc_data($path, $format = 'json')
 {
     $output_cache_file = dirname(__DIR__) . '/cache-phpdoc.json';
     /**
      * Force delete last cache of phpdoc
      * Compare directory and WordPress Version for detecting
      */
     $delete_output_cache_file = false;
     $wp_parser_root_import_dir = get_option('wp_parser_root_import_dir', '');
     $directory_to_compare = wp_normalize_path(__DIR__);
     if (false !== strpos($wp_parser_root_import_dir, $directory_to_compare)) {
         $current_wp_version = get_bloginfo('version');
         $wp_parser_imported_wp_version = get_option('wp_parser_imported_wp_version', $current_wp_version);
         $delete_output_cache_file = $wp_parser_imported_wp_version != $current_wp_version;
     }
     /**
      * Delete last cache of phpdoc, true for deleting or false to skip
      *
      * Default: false or compare wordpress version see above
      */
     $delete_output_cache_file = apply_filters('sublime_delete_phpdoc_output_cache', $delete_output_cache_file);
     if ($delete_output_cache_file) {
         if (false !== stream_resolve_include_path($output_cache_file)) {
             unlink($output_cache_file);
         }
     }
     if (false !== stream_resolve_include_path($output_cache_file)) {
         if ($output = file_get_contents($output_cache_file)) {
             $output = 'json' == $format ? $output : json_decode($output, true);
         }
     } else {
         WP_CLI::line(sprintf('Extracting PHPDoc from %s. This may take a few minutes...', $path));
         $is_file = is_file($path);
         $files = $is_file ? array($path) : Importer::set_parser_phpdoc($path);
         $path = $is_file ? dirname($path) : $path;
         if ($files instanceof WP_Error) {
             WP_CLI::error(sprintf('Problem with %1$s: %2$s', $path, $files->get_error_message()));
             exit;
         }
         $output = Importer::get_parser_phpdoc($files, $path);
         /**
          * Generate cache file from phpdoc, true for generate or false to skip
          *
          * Default: true
          */
         if (apply_filters('sublime_create_phpdoc_output_cache', true)) {
             file_put_contents($output_cache_file, json_encode($output, JSON_PRETTY_PRINT));
         }
         if ('json' == $format) {
             $output = json_encode($output, JSON_PRETTY_PRINT);
         }
     }
     if ($helper_directory = realpath(dirname(__DIR__) . '/missing')) {
         $helpers = glob($helper_directory . '/*.php');
         if (is_array($helpers)) {
             $output = array_merge($output, Importer::get_parser_phpdoc($helpers, $helper_directory));
         }
     }
     return $output;
 }
 public function page_init()
 {
     register_setting('extrp', 'extrp_option', array($this, 'sanitize'));
     register_setting('extrp_tool', 'extrp_option_tool', array($this, 'sanitize'));
     $this->with_relevanssi = get_option('extrp_with_relevanssi');
     $this->plugin_data = get_plugin_data(wp_normalize_path(EXTRP_PLUGIN_PATH . '/extended-related-posts.php'));
     $this->updates = extrp_plugin_updates();
 }
예제 #9
0
 public function dashboard_notice()
 {
     $path = wp_normalize_path(Upfront::get_root_dir() . '/library/external/dashboard-notice/wpmudev-dash-notification.php');
     if (!file_exists($path)) {
         return false;
     }
     require_once $path;
 }
 /**
  * Make sure setting a custom path + database dump filename correctly sets the database dump filepath
  *
  */
 public function testCustomDatabaseDumpPath()
 {
     HM\BackUpWordPress\Path::get_instance()->set_path(WP_CONTENT_DIR . '/custom');
     $this->backup->set_database_dump_filename('dump.sql');
     $this->assertEquals(wp_normalize_path(WP_CONTENT_DIR . '/custom/dump.sql'), $this->backup->get_database_dump_filepath());
     $this->backup->dump_database();
     $this->assertFileExists($this->backup->get_database_dump_filepath());
 }
예제 #11
0
 /**
  * @ticket 29154
  */
 function test_should_return_correct_basename_for_symlinked_plugins()
 {
     global $wp_plugin_paths;
     $old_wp_plugin_paths = $wp_plugin_paths;
     $wp_plugin_paths[wp_normalize_path(WP_PLUGIN_DIR) . '/a-symlinked-plugin'] = 'C:/www/path/plugins/a-plugin';
     $basename = plugin_basename('c:\\www\\path\\plugins\\a-plugin\\plugin.php');
     $wp_plugin_paths = $old_wp_plugin_paths;
     $this->assertSame('a-symlinked-plugin/plugin.php', $basename);
 }
 private function _map_file_to_relative_origin($file)
 {
     $file = wp_normalize_path(realpath($file));
     $plugin_path_rx = preg_quote(wp_normalize_path(WP_PLUGIN_DIR), '/');
     $muplugin_path_rx = preg_quote(wp_normalize_path(WPMU_PLUGIN_DIR), '/');
     $theme_path_rx = preg_quote(wp_normalize_path(get_theme_root()), '/');
     $path_prefix = false;
     if (preg_match('/^' . $plugin_path_rx . '/', $file)) {
         $path_prefix = $plugin_path_rx;
     } else {
         if (preg_match('/^' . $muplugin_path_rx . '/', $file)) {
             $path_prefix = $muplugin_path_rx;
         } else {
             if (preg_match('/^' . $theme_path_rx . '/', $file)) {
                 $path_prefix = $theme_path_rx;
             }
         }
     }
     if (empty($path_prefix)) {
         return $this->_get_l10n(self::ORIGIN_INTERNAL);
     }
     // Not a pugin, mu-plugin or a theme
     $clean_path = explode('/', ltrim(preg_replace('/^' . $path_prefix . '/', '', $file), '/'));
     $basename = !empty($clean_path[0]) ? $clean_path[0] : false;
     if (empty($basename)) {
         return $this->_get_l10n(self::ORIGIN_INTERNAL);
     }
     // We had an issue along the way and can't figure it out further
     if (!function_exists('get_plugin_data')) {
         require_once ABSPATH . 'wp-admin/includes/plugin.php';
     }
     $all_plugins = get_plugins();
     if ($path_prefix === $plugin_path_rx || $path_prefix === $muplugin_path_rx) {
         // It's a plugin, get the name
         $info = false;
         foreach ($all_plugins as $plugin => $pinfo) {
             if (!preg_match('/^' . preg_quote(trailingslashit($basename), '/') . '/', $plugin)) {
                 continue;
             }
             $info = $pinfo;
             break;
         }
         if (empty($info)) {
             // Let's give it one last go for mu-plugins
             $info = get_plugin_data($file);
         }
         return !empty($info['Name']) ? $info['Name'] : $this->_get_l10n(self::ORIGIN_PLUGIN);
     } else {
         if ($theme_path_rx === $path_prefix) {
             $info = wp_get_theme($basename);
             $name = is_object($info) && method_exists($info, 'get') ? $info->get('Name') : false;
             return !empty($name) ? $name : $this->_get_l10n(self::ORIGIN_THEME);
         }
     }
     return $this->_get_l10n(self::ORIGIN_INTERNAL);
 }
예제 #13
0
 /**
  * Get the path to the directory where backups will be stored
  */
 public function get_path()
 {
     // Calculate the path if needed
     if (empty($this->path) || !wp_is_writable($this->path)) {
         $this->calculate_path();
     }
     // Ensure the backup directory is protected
     $this->protect_path();
     return wp_normalize_path($this->path);
 }
 /**
  * Make all slashes unique.
  *
  * @param string $path
  *
  * @return string
  */
 private function normalize_path($path)
 {
     // WP 3.9 and newer.
     if (function_exists('wp_normalize_path')) {
         return wp_normalize_path($path);
     }
     $path = str_replace('\\', '/', $path);
     $path = preg_replace('|/+|', '/', $path);
     return $path;
 }
/**
 * filter of template path
 * use it to modified the theme
 *
 * @since 1.0.0
 *
 * fixes variables
 *
 * @since 1.1.6
 *
 */
function stt2extat_template_path()
{
    $template_name = get_option('stt2extat_template_name');
    $template_path = wp_normalize_path(STT2EXTAT_PATH_LIB_CONTENT . 'templates/');
    $path = $template_path . 'default';
    if ($template_name) {
        $path = $template_path . $template_name;
    }
    return $path;
}
예제 #16
0
 public static function route($page = '')
 {
     if ($page == "pressapps-help") {
         include_once wp_normalize_path(plugin_dir_path(__FILE__) . '/template/help.php');
     } else {
         if ($page == "pressapps-product") {
             include_once wp_normalize_path(plugin_dir_path(__FILE__) . '/template/products.php');
         }
     }
 }
예제 #17
0
파일: Util.php 프로젝트: L0k1slnk/weddly
 public static function standard_dir($dir, $abspath_replace = null)
 {
     $dir = wp_normalize_path($dir);
     if (is_string($abspath_replace)) {
         if (!self::$abspath) {
             self::$abspath = wp_normalize_path(ABSPATH);
         }
         $dir = str_replace(self::$abspath, $abspath_replace, $dir);
     }
     return $dir;
 }
예제 #18
0
 public static function standard_dir($dir, $path_replace = null)
 {
     $dir = wp_normalize_path($dir);
     if (is_string($path_replace)) {
         if (!self::$abspath) {
             self::$abspath = wp_normalize_path(ABSPATH);
             self::$contentpath = wp_normalize_path(dirname(WP_CONTENT_DIR) . '/');
         }
         $dir = str_replace(array(self::$abspath, self::$contentpath), $path_replace, $dir);
     }
     return $dir;
 }
예제 #19
0
 function cs_get_path_locate()
 {
     $dirname = wp_normalize_path(dirname(__FILE__));
     $plugin_dir = wp_normalize_path(WP_PLUGIN_DIR);
     $located_plugin = preg_match('#' . $plugin_dir . '#', $dirname) ? true : false;
     $directory = $located_plugin ? $plugin_dir : get_template_directory();
     $directory_uri = $located_plugin ? WP_PLUGIN_URL : get_template_directory_uri();
     $basename = str_replace(wp_normalize_path($directory), '', $dirname);
     $dir = $directory . $basename;
     $uri = $directory_uri . $basename;
     return apply_filters('cs_get_path_locate', array('basename' => wp_normalize_path($basename), 'dir' => wp_normalize_path($dir), 'uri' => $uri));
 }
 public function loadTextDomain($domain = null, $path = null)
 {
     /** @var PluginInterface $this */
     $domain = $domain !== null ? $domain : $this->getTextDomain();
     $path = $path !== null ? $path : $this->getDomainPath();
     $file = wp_normalize_path($this->getFile());
     $muPluginDir = wp_normalize_path(WPMU_PLUGIN_DIR);
     if (strpos($file, $muPluginDir) === 0) {
         $path = basename($this->getDirectory()) . $path;
         return load_muplugin_textdomain($domain, $path);
     }
     return load_plugin_textdomain($domain, false, $path);
 }
예제 #21
0
 /**
  * Get LESS directories.
  */
 function get_less_directories($type)
 {
     if ($type == 'add-ons') {
         $type = 'components';
     }
     global $_beans_uikit_enqueued_items;
     // Define uikit src directory.
     $directories = array(BEANS_API_COMPONENTS_PATH . 'uikit/src/less/' . $type);
     // Add the registered theme directories.
     foreach ($_beans_uikit_enqueued_items['themes'] as $id => $directory) {
         $directories[] = wp_normalize_path(untrailingslashit($directory));
     }
     return $directories;
 }
 /**
  * Assert that a zip archive contains the array
  * of filenames
  *
  * @param string path to zip file
  * @param array of filenames to check for
  * @return null
  */
 function assertArchiveContains($zip_file, $filepaths, $root = ABSPATH)
 {
     $extracted = $this->pclzip_extract_as_string($zip_file);
     $files = array();
     foreach ($filepaths as $filepath) {
         $filenames[] = str_ireplace(trailingslashit($root), '', wp_normalize_path((string) $filepath));
     }
     foreach ($extracted as $fileInfo) {
         $files[] = untrailingslashit($fileInfo['filename']);
     }
     foreach ($filenames as $filename) {
         $this->assertContains($filename, $files);
     }
 }
예제 #23
0
 private function wp_normalize_path($path)
 {
     // wp_normalize_path is not present before WP 3.9
     if (function_exists('wp_normalize_path')) {
         return wp_normalize_path($path);
     }
     // Taken from WP 4.6
     $path = str_replace('\\', '/', $path);
     $path = preg_replace('|(?<=.)/+|', '/', $path);
     if (':' === substr($path, 1, 1)) {
         $path = ucfirst($path);
     }
     return $path;
 }
/**
 * Register control scripts/styles.
 *
 * @since  1.0.0
 * @access public
 * @return void
 */
function customize_background_controls_register_scripts()
{
    // Since this can be used as a drop-in library
    // We'll load the JS relative to this PHP file
    $file = dirname(__FILE__);
    // Get the URL and path to wp-content
    $content_url = untrailingslashit(dirname(dirname(get_stylesheet_directory_uri())));
    $content_dir = untrailingslashit(WP_CONTENT_DIR);
    // Fix path on Windows servers
    $file = wp_normalize_path($file);
    $content_dir = wp_normalize_path($content_dir);
    $uri = str_replace($content_dir, $content_url, $file);
    wp_register_script('customizer-background-image-controls', esc_url($uri . '/js/customize-controls.js'), array('customize-controls'));
}
예제 #25
0
 /**
  * Create the widget
  *
  * @access      public
  * @since       1.0.0
  * @param       array $args The widget arguements
  * @param       array $instance This widget instance
  * @return      void
  */
 public function widget($args, $instance)
 {
     $title = apply_filters('widget_title', $instance['title'], $instance, $args['id']);
     $payment_methods = edd_get_option('accepted_cards', array());
     $icon_width = isset($instance['icon_width']) ? $instance['icon_width'] . 'px' : '32px';
     if (empty($payment_methods)) {
         return;
     }
     echo $args['before_widget'];
     if ($title) {
         echo $args['before_title'] . $title . $args['after_title'];
     }
     do_action('edd_before_payment_icons_widget');
     echo '<div class="edd-payment-icons-widget">';
     if ($instance['above_icons']) {
         echo '<div class="edd-payment-icons-widget-text">';
         echo html_entity_decode(esc_html($instance['above_icons']));
         echo '</div>';
     }
     foreach ($payment_methods as $key => $card) {
         if (edd_string_is_image_url($key)) {
             echo '<img class="payment-icon" src="' . esc_url($key) . '" style="width: ' . $icon_width . '" />';
         } else {
             $card = strtolower(str_replace(' ', '', $card));
             if (has_filter('edd_accepted_payment_' . $card . '_image')) {
                 $image = apply_filters('edd_accepted_payment_' . $card . '_image', '');
             } else {
                 $image = edd_locate_template('images' . DIRECTORY_SEPARATOR . 'icons' . DIRECTORY_SEPARATOR . $card . '.gif', false);
                 $content_dir = WP_CONTENT_DIR;
                 if (function_exists('wp_normalize_path')) {
                     $image = wp_normalize_path($image);
                     $content_dir = wp_normalize_path($content_dir);
                 }
                 $image = str_replace($content_dir, WP_CONTENT_URL, $image);
             }
             if (edd_is_ssl_enforced() || is_ssl()) {
                 $image = edd_enforced_ssl_asset_filter($image);
             }
             echo '<img class="payment-icon" src="' . esc_url($image) . '" style="width: ' . $icon_width . '" />';
         }
     }
     if ($instance['below_icons']) {
         echo '<div class="edd-payment-icons-widget-text">';
         echo html_entity_decode($instance['below_icons']);
         echo '</div>';
     }
     echo '</div>';
     do_action('edd_after_payment_icons_widget');
     echo $args['after_widget'];
 }
예제 #26
0
/**
 * Load core classes according to WordPress naming conventions.
 *
 * @link  https://make.wordpress.org/core/handbook/coding-standards/php/#naming-conventions
 *
 * @param string $class Class name
 *
 * @since 1.0.0
 */
function appica_loader($class)
{
    $chunks = array_filter(explode('_', strtolower($class)));
    // Load only plugins classes
    $fchunk = reset($chunks);
    if (false === $fchunk || 'appica' !== $fchunk) {
        return;
    }
    $root = APPICA_CORE_ROOT . '/core/';
    $file = 'class-' . implode('-', $chunks) . '.php';
    $path = wp_normalize_path($root . $file);
    if (is_readable($path)) {
        require $path;
    }
}
예제 #27
0
/**
 * Send the download file to the browser and then redirect back to the backups page
 */
function request_download_backup()
{
    check_admin_referer('hmbkp_download_backup', 'hmbkp_download_backup_nonce');
    if (!file_exists(sanitize_text_field(base64_decode($_GET['hmbkp_backup_archive'])))) {
        return;
    }
    $url = str_replace(wp_normalize_path(Path::get_home_path()), home_url('/'), trailingslashit(dirname(sanitize_text_field(base64_decode($_GET['hmbkp_backup_archive']))))) . urlencode(pathinfo(sanitize_text_field(base64_decode($_GET['hmbkp_backup_archive'])), PATHINFO_BASENAME));
    global $is_apache;
    if ($is_apache) {
        Path::get_instance()->protect_path('reset');
        $url = add_query_arg('key', HMBKP_SECURE_KEY, $url);
    }
    wp_safe_redirect($url, 303);
    die;
}
예제 #28
0
 /**
  * Gets the path to a translation file.
  *
  * @access protected
  * @return string Absolute path to the translation file.
  */
 protected function get_path()
 {
     $path_found = false;
     $found_path = null;
     foreach ($this->get_paths() as $path) {
         if ($path_found) {
             continue;
         }
         $path = wp_normalize_path($path);
         if (file_exists($path)) {
             $path_found = true;
             $found_path = $path;
         }
     }
     return $found_path;
 }
예제 #29
0
function theme_basename($file)
{
    global $wp_plugin_paths;
    foreach ($wp_plugin_paths as $dir => $realdir) {
        if (strpos($file, $realdir) === 0) {
            $file = $dir . substr($file, strlen($realdir));
        }
    }
    $file = wp_normalize_path($file);
    $plugin_dir = wp_normalize_path(get_template_directory());
    $mu_plugin_dir = wp_normalize_path(get_template_directory());
    $file = preg_replace('#^' . preg_quote($plugin_dir, '#') . '/|^' . preg_quote($mu_plugin_dir, '#') . '/#', '', $file);
    // get relative path from plugins dir
    $file = trim($file, '/');
    return $file;
}
예제 #30
0
 /**
  * Get plugin base path and URL.
  * The method is static and can be used in extensions.
  * @link http://www.deluxeblogtips.com/2013/07/get-url-of-php-file-in-wordpress.html
  * @param string $path Base folder path
  * @return array Path and URL.
  */
 public static function get_path($path = '')
 {
     // Plugin base path
     $path = wp_normalize_path(untrailingslashit($path));
     $content_dir = wp_normalize_path(untrailingslashit(WP_CONTENT_DIR));
     // Default URL
     $url = plugins_url('', $path . '/' . basename($path) . '.php');
     // Included into themes
     if (0 !== strpos($path, wp_normalize_path(WP_PLUGIN_DIR)) && 0 !== strpos($path, wp_normalize_path(WPMU_PLUGIN_DIR)) && 0 === strpos($path, $content_dir)) {
         $content_url = untrailingslashit(dirname(dirname(get_stylesheet_directory_uri())));
         $url = str_replace($content_dir, $content_url, $path);
     }
     $path = trailingslashit($path);
     $url = trailingslashit($url);
     return array($path, $url);
 }