How to check if txt file exists inside template folder?
You are trying to check it by URL, which makes no sense to is_file() which expects local path. By the way I’d use file_exists() instead. Try: $fileName1 = TEMPLATEPATH . ‘/txtfolder/file1.txt’;
You are trying to check it by URL, which makes no sense to is_file() which expects local path. By the way I’d use file_exists() instead. Try: $fileName1 = TEMPLATEPATH . ‘/txtfolder/file1.txt’;
Most of the time, if you are doing things right you don’t have to include Core files. If you are doing things right they will already be loaded for you. In those case where they aren’t loaded, trying to load files with “directory traversal” paths is the wrong way. The Core constants ABSPATH and WPINC … Read more
Yes, you can use a /wp-content/mu-plugins folder for single file autoloading plugins. The only thing you will have to do is to use a plugin header comment in this file: <?php /* Plugin Name: I am a MU-Plugin */ Then you will find a link on top of your /wp-admin/plugins.php page that says “Must-Use Plugins” … Read more
This is essentially scope visibility issue. include brings code into a current scope, function call creates new closed off scope. In get_template_part() only certain WordPress globals are being made available by load_template() call inside. While the basic answer is to declare your variables as globals, you might want to ponder your overall architecture a bit … Read more
A script loaded within a function call will only work within the immediate scope of where require or include was used. So really only variables present when load_template() is called will be accessible to the loaded script (unless you use global $myvar of course). The reason vars like $post and $wp_query are available to the … Read more
Take a look at what wp_parse_auth_cookie() does. You can easily duplicate that given the fact that you have all the Cookie constants available. Still, I’d highly advise against that. In your case, I’d try to integrate as far with WordPress as I can to avoid duplicating an authentication mechanism. You can always use any custom … Read more
You can… Load the file into the file where you want to display the ‘hey username’ message: <?php include(TEMPLATEPATH .’/check-user-hello.php’); ?> . Then in that file “check-user-hello.php” You need to put this code <?php if ( is_user_logged_in() ) { global $current_user; get_currentuserinfo(); echo ‘Hey ‘ . $current_user->display_name; } else { echo ‘<a href=”‘. get_bloginfo(‘url’) .’/wp-admin” … Read more
If you just need that class included, and your script is located in the plugin directory, like /wp-content/plugins/pluginName/script.php, then you can do: require realpath(‘../../../wp-includes/class-phpass.php’);
You need to have the script in a separate file (normally it would be filename.js; I suppose filename.php would work?). Then, you need to register and enqueue that script file, using wp_register_script() and wp_enqueue_script() e.g.: function mytheme_register_custom_scripts() { if ( ! is_admin() ) { $scriptsrc = get_stylesheet_directory_uri() . ‘/scripts/filename.js’; wp_register_script( ‘mytheme_slider’, $scriptsrc ); } } … Read more
Unfortunately not at the moment. If you look in wp-includes/default_constants.php, the WP_CONTENT_DIR and other constants all have a if ( ! defined(constant) ) check before them. WPINC (the wp-includes constant) does not. It’s defined in wp-settings.php, and has no if ( ! defined(WPINC) ) check, so defining it before hand (in your wp-config.php) would just … Read more