i have look for Wordpress theme detector but i have no idea how it works and how to detect wordpress activated theme into theme folder. like https://theseotools.net/wp-theme-detector
please help me how can i did this.
I wrote this code for the purpose of readability. Normally, people would spend more than 10 lines of code fetching the name of an active wordpress template. There might be some minor adaptions needed, but nevertheless, this works. So, first we fetch the source code for the home page. Then we use regex to find style.css, then we use regex to fetch the name (refer to wordpress style sheet conventions), and yay we now have the name of the active theme. You can even get the download URI from here, as well.
<?php
$targetSite = ""; // put your wordpress url here
$src = file_get_contents($targetSite);
preg_match("/\<link rel='stylesheet'.*href='(.*?style\.css.*?)'.*\>/i",$src,$matches);
$styleHref = trim($matches[1]);
$styleSrc = file_get_contents($styleHref);
preg_match("/\Theme Name:(.*?)\n/i",$styleSrc,$name);
echo(trim($name[1]));
?>
Related
I use wordpress and ACF. I use $link in the template, for example:
$link = get_field('custom_link');
After that, I wrote a code that checks the url for identifiers and if there are matches, then replaces $link['url'], $link['title'] and $link['target'] with "options".
Next comes:
<?php echo esc_html($link_title); ?>
This all works in a build, but I'm trying to use the same code on all links in all templates, so I created a "links.php" file and pasted my link checking code in there.
In the template, I tried to call the file with get_template_part and include. Also, I've tried include(locate_template('links.php')), but that doesn't work either.
Can someone tell me how to properly use repeatable code in ACF templates?
Everything worked using:
include(locate_template('folder1/links.php'));
The template was located in the folder with the theme in "folder2", and the link file in "folder1".
Before that, I tried:
include(locate_template(' ../folder1/links.php'));
and various variations, but I did not think that the path is taken from the theme folder.
so we are making a wordpress site that automatically adds a link to a comment every time a comment is created. The theme we are using is html5 blank. I have written several lines of code into its function.php. however it is not working right now, here is what i wrote:
function bo_wrap_comment_text($content) {
$content = get_comment_text();
$texta = urlencode(get_comment_text());
$textb = "http://www.google.com/search?btnI&q=" + $texta;
return ''.$content.'';
}
add_filter('wp_insert_comment','bo_wrap_comment_text',1000);
a separate code(this one works) is tested here: http://phpfiddle.org and the code is:
<?php
$texta='i hate apple';
$textb=urlencode($texta);
$textc= "http://www.google.com/search?btnI&q=".$textb;
echo ''.$texta.'';
?>
the wordpress site is here. It is simply a static front page. the title you see there is the title of comment area. everything related with blog posts has been hidden using css. we have manually added links to several comments as prototyping. what we want is replace manual work with wordpress functions. I would really appreciate any help.
You need this hook instead to edit comment data:
http://codex.wordpress.org/Plugin_API/Filter_Reference/preprocess_comment
How to add css to specific wordpress user to hide plugin fiction over front end? I installed the wp-about-author plugin but I need to set as hidden for admin user. So when the admin make any blog post then the wp-about-author wont be displayed. Unfortunately no feedback from the plugin developer. Thanks for any suggestions.
CSS way is not recommended since the user can check out actual DOM by view the source.
Instead, You can prevent from even showing up in the DOM Tree by modifying a plugin php file.
$level = get_the_author_meta('user_level');
if ($level == 10) {
return;
}
Add this line to wp-about-author.php on line #31.
This works, I tested.
Try to update plugin better then hack css :) You can add to wp-about-author.php on line #102 something like:
if (wp_admin()) $return_content = '';
I didn't check it, but might work for you.
i've written a plugin which shortcodes can easily be used in every post and page. As this plugin can be useful in a sidebar as well i want to make the text widget usable for my shortcodes.
When i googled this i found out that i can use the add_filter() function to ensure that, but this is only possible if i have access to the theme's functions.php. But as i am the creator of the plugin and not of the theme, this is not usable for me.
Does anybody know how i can make a shortcode which is introduced with a plugin usable in the widgets section?
Thanks!
Open your theme's function file.
Find a free spot after the opening php tag that isn't part of a function.
add this:
if (!is_admin())
{
add_filter('widget_text', 'do_shortcode', 11);
}
save the file and you should be all set.
Open your page in edit mode.
Select your page location and line where you want to add short code.
Add code here and update..
My question: Is there any way of showing the visitor's IP address in the title of a page on Wordpress? What I've done so far is this: My IP Lookup.
Is there any plugin or a tweak that I can do to?
Here's the file: Header.php
Please help!!
I'm the author of the theme and its framework. I'm just going to modify the code that Matthew gave you a bit. For future updates to the theme and framework, it's better if you can avoid actually editing header.php in your Child theme, but instead utilize the framework's hook system:
http://www.wpjumpstart.com/tutorial/primary-framework-action-hooks/
themeblvd_title is one of the framework's actions. It has a default function already hooked onto it that displays the title the way you see it now. What you want to do is fairly easy because you're not actually modifying that default function, but instead just adding onto the action.
If the concept of action hooks in general is completely foreign to you, definitely check out this article -- www.wpjumpstart.com/tutorial/actions/ -- Understanding these basic WordPress development concepts is really going to expand what you're going to be able to do moving forward with your customizations.
So to accomplish what Mathew said, you'd do the following from the functions.php of your Child theme:
function my_title_addon() {
if (is_page(10)) { //Check if we are on the correct page
echo '|'; //Just a spacer between the default title and your addition
do_shortcode('[shortcode]');
}
}
add_action( 'themeblvd_title', 'my_title_addon' );
There's also one big thing to note here, as well. I noticed on your site, you're using Alyeska 2.0. You should update to the latest version Alyeska 2.1 posted last week on ThemeForest, which incorporates v2.1 of the framework. Inside is a new sample child theme that incorporates a slightly modified structure, as outlined in this video -- vimeo.com/41331677
If you do not use this new child theme structure, the above code I posted will add your IP shortcode to the start of themeblvd_title, which isn't what you want. If you elect to keep your current theme version and Child theme structure, the above add_action needs to have a priority higher than the default 10 like this:
function my_title_addon() {
if (is_page(10)) { //Check if we are on the correct page
echo '|'; //Just a spacer between the default title and your addition
do_shortcode('[shortcode]');
}
}
add_action( 'themeblvd_title', 'my_title_addon', 11 ); // Higher priority so it comes after default title function
Here is how you can use a filter hook to modify the title.
Add this in a theme functions.php file or one of your own plugins:
add_filter( 'wp_title', 'add_ip_to_title', 10, 3 );
function add_ip_to_title($title, $sep = '', $location = '') {
return $title . $sep . "visitor IP info here";
}
https://codex.wordpress.org/Plugin_API/Filter_Reference/wp_title
Edit your header.php file in your theme. That is where the tag is generated. It should be wp-content/themes/alyeska-child/header.php or if it isn't there wp-content/themes/alyeska/header.php.
If you post the code that is generating your title (or your header.php file if you can't tell), we can tell you where to add it specifically.
If the IP info is generated via a shortcode, you can use do_shortcode('[shortcode]) in your PHP to run the shortcode directly with PHP.
If you wanted to do this on just one page, you would have to detect the correct page and conditionalize the change to the title. You need to know a page identifyer for the page you want, but you would use something like:
<title>
<?php
themeblvd_title();
if (is_page(10)) { //Check if we are on the correct page
echo '|'; //Just a spacer between the default title and your addtion
do_shortcode('[shortcode]');
}
?>
</title>
More information on is_page: http://codex.wordpress.org/Function_Reference/is_page
To add to some of the other answers, to get their IP address, it could vary a little bit depending upon your server environment. Just make a file called test.php and put it in a web accessible place:
<?php
echo phpinfo();
?>
Then, look for a place where you can retrieve the user's IP address. If your PHP is running in a reverse proxy, unfortunately, the normal place will just have localhost's IP. But there are a lot of other environmental variables you can grab the IP from. Here are the places to check:
"Apache Environment" or "HTTP Headers Information" or under the "PHP Variables" section.
Then, if you see the real IP address (compare the address shown on the info page with what you might get from whatismyip.com) then you can access that value in the function described above by drew010 using one of PHP's predefined variables.