I am using a wordpress theme that contains several language files. I would like to modify a language file to "white label" the theme I am using. I will also be making other admin-css changes to the theme, therefore, I'd like to create a plugin that allows me to do all of this.
What I am unsure of how to do is create a custom plugin that would override a themes language file - is this possible?
I have so far tried this:
<?php
/*
Plugin Name: Layers Whitelabel test
Plugin URI: http://www.skizzar.com
Description: Plugin to whitelabel layers for Skizzar
Author: Skizzar
Version: 1.0
Author URI: http://www.skizzar.com
*/
function set_myplugins_languages() {
load_textdomain( 'layerswp', plugin_dir_url( __FILE__ ) . '/language' );
}
add_action('init', 'set_myplugins_languages');
But so far no joy - as in, it doesn't load the new language file in place of the existing one.
Anyone got any ideas on how this can be achieved?
Well, why do you need a plugin for this?
The theme style.css have similar code to
Plugin Name: Layers Whitelabel test
Plugin URI: http://www.skizzar.com
Description: Plugin to whitelabel layers for Skizzar
Author: Skizzar
Version: 1.0
Author URI: http://www.skizzar.com
So you can simply change theme display name, url, author etc.
Basically it's easy to do, however it's against theme copyrighting ;) Even if this is a GPL theme you should refer to original developer.
Related
I have a fresh WordPress and bbPress installed on an internal server.
While I was setting up bbPress I wanted to test the functionalities like creating a forum, topic, etc. When doing these stuff in the back-end (dashboard) there didn't seem to be any problems but when I did it from the front-end I kept getting
ERROR: Are you sure you wanted to do that?
I searched for a solution and found this.
add_filter( 'bbp_verify_nonce_request_url', 'my_bbp_verify_nonce_request_url', 999, 1 );
function my_bbp_verify_nonce_request_url( $requested_url )
{
return 'http://localhost:8888' . $_SERVER['REQUEST_URI'];
}
I simply changed the hard-coded URL to what our internal server is set up to and it fixed the problem.
Now my question: is it possible for me to add this solution to a functions.php that is independent of the theme being used? I asked this because I have 2 concerns:
The current theme might get updated and will overwrite the file
I'm aware that the solution to this is simply create a child theme but my second concern prevents me from doing this.
The WordPress administrator might change themes and so both the functions.php file on the main theme and the child theme will stop working
How could I add the solution above so that I don't have to worry about the theme being updated and/or replaced with a new theme in the future? I don't want to keep adding this solution every time the administrator decides to change themes.
If you can't put it in a theme, put it in a Plugin. If you're worried that the plugin will get de-activated make it a Must Use Plugin.
It's dead simple to create a plugin. Create a file plugin-name.php and place it in a directory wp-content/plugins/plugin-name/. That file should contain the following code:
<?php
/*
Plugin Name: Name Of The Plugin
Plugin URI: http://URI_Of_Page_Describing_Plugin_and_Updates
Description: A brief description of the Plugin.
Version: The Plugin's Version Number, e.g.: 1.0
Author: Name Of The Plugin Author
Author URI: http://URI_Of_The_Plugin_Author
License: A "Slug" license name e.g. GPL2
*/
add_filter( 'bbp_verify_nonce_request_url', 'my_bbp_verify_nonce_request_url', 999, 1 );
function my_bbp_verify_nonce_request_url( $requested_url )
{
return 'http://localhost:8888' . $_SERVER['REQUEST_URI'];
}
If you want it to be a must use plugin, put it in wp-content/mu-plugins/ instead of wp-content/plugins.
so i testing my them from errs with theme check plugin
and go the text domain issue but it returns a blank value ! is this make any since !!
REQUIRED: This theme text domain does not match the theme's slug. The text domain used: This theme's correct slug and text-domain is osiris-rathemes.
/*
Theme Name: osiris rathemes
Theme URI: https://themeforest.net/user/ra-themes/portfolioa
Author: Mohamed Said
Author URI: https://themeforest.net/user/ra-themes
Description: some dec
Version: 1.0
License: GNU General Public License v2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html
Text Domain: osiris-rathemes
This theme, like WordPress, is licensed under the GPL.
Use it to make something cool, have fun, and share what you've learned with others.
*/
theme folder name as the text domain
and the style.css have the text domain and its not an empty string
do i miss any thing !
Maybe you need to load the theme textdomain in the functions.php file. Your style.css file looks correct but I don't know what your theme plugin checker is doing..
function osiris_rathemes_setup() {
load_theme_textdomain( 'osiris-rathemes', get_template_directory() . '/languages' );
}
add_action( 'after_setup_theme', 'osiris_rathemes_setup' );
Im trying to delete the section WordPress News in my dashboard by creating a simple plugin. First of all, i've made a php file in the following directory:
wp-content/plugins/basic-plugin.php
In the basic-plugin.php file i have the following block of code:
<?php
/*
Plugin Name: Basic Plugin
Plugin URI: http://wordpress.org/plugins/basic-plugin/
Description: My first plugin for creating and displaying job opportunities
Author: Rumen Panchev
Version: 1.0
License: GPLv2
*/
function ru_remove_dashboard_widget() {
remove_meta_box( 'dashboard_primary', 'dashboard', 'post_container_1' );
}
add_action( 'wp_dashboard_setup', 'ru_remove_dashboard_widget' );
The problem is that the section is still in the dashboard. Im new in WordPress Development and not sure why is this happening ?
Your approach is correct however you're using the wrong context argument with remove_meta_box(). Dashboard widgets aren't registered under post_container_1.
Valid options for the context argument include 'normal', 'advanced' or 'side'. For the particular dashboard widget you're attempting to remove, you need 'side'.
remove_meta_box( 'dashboard_primary', 'dashboard', 'side' );
Documentation: https://codex.wordpress.org/Function_Reference/remove_meta_box
I am having the hardest time trying to modify the woocommerce layout for the storefont template. My directory is:
Location for woocommerce plugin: wp-content/plugins/woocommerce/templates
I copy everything in the templates folder above into: wp-content/themes/storefront_child/woocommerce/
Modify any file inside the woocommerce folder above such as writing
OMG anywhere on the page.
Nothing shows in my page.
I am a rookie in WordPress and I have no idea how to modify the files for a plugin/template. I have not activated my child template either (is that required?). When I duplicate the woocommerce files and try to install them, it says the template is missing.
open up functions.php
then copy below code on there:
add_action( 'after_setup_theme', 'woocommerce_support' );
function woocommerce_support() {
add_theme_support( 'woocommerce' );
}
and then check the result
I finally got it after much research. Most sites neglect to mention that what actually "activates" the child theme is the comment in the CSS. So the child theme MUST include the CSS with the information that links it to the parent child. In my case:
/*
Theme Name: storefront-child
Theme URI: http://example.com/
Description: StoreFront
Author: John Doe
Author URI: http://example.com
Template: storefront
Version: 1.3.1
License: GNU General Public License v2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html
Tags: light, dark, two-columns, right-sidebar, responsive-layout, accessibility-ready
Text Domain: twenty-fifteen-child
*/
It seems your child theme has not configured properly. You please double check below points.
You activated Child Theme (Not the parent)
Your child theme has a style.css file with below code
/*
Theme Name: My Child Theme
Description: A Twenty Thirteen child theme
Author: My author
Template: twentythirteen
Version: 1.0.0
*/
You properly Enqueued the Styles and Scripts.
add_action( 'wp_enqueue_scripts', 'my_theme_add_stylesheet' );
function my_theme_add_stylesheet() {
wp_enqueue_style( 'my-style', get_stylesheet_directory_uri() . '/style.css', false, '1.0', 'all' );
}
1. Shortcode (working)
I have made a Shortcode which display the current weatherinformations from yahoo. There was 3 Files (simple-pie.inc, simple-pie-yahoo.inc and yahooweather.php) and I grabed the content of these files and pasted it inside my function.php – works good!
This looks so and got more then 16.000 Lines of Code:
// Add Shortcode for weather
function get_rohrau_wetter() {
content of simple-pie.inc
content of simple-pie-yahoo.inc
content of yahooweather.php -> return "weather-html"
}
add_shortcode( 'rohrauwetter', 'get_rohrau_wetter' );
2. Plugin (no clue where to start)
All I want to do is making a Plugin out of my working shortcode to get that "wall-of-code" out of my function.php and of course for better reuseability. Also I think so it will be possible to turn the simple-pie cache to "on" for faster processing…
My Question is: How do I convert my Shortcode into an Plugin?
A good place to start would the plugin handbook: https://developer.wordpress.org/plugins/the-basics/header-requirements/
But the cheap and nasty way to place it into a plugin, create a directory for your plugin, create a index.php (realistically it can be any name) file. Add this in
<?php
/*
Plugin Name: WordPress.org Plugin
Plugin URI: https://developer.wordpress.org/plugins/the-basics/
Description: Basic WordPress Plugin Header Comment
Version: 20160911
Author: WordPress.org
Author URI: https://developer.wordpress.org/
License: GPL2
License URI: https://www.gnu.org/licenses/gpl-2.0.html
Text Domain: wporg
Domain Path: /languages
*/
Then underneath it add in your above functions. Obviously Change out the text to suit yourself so that you can identify the plugin. Then upload it too your plugins directory.
As I said, this is the cheap and nasty way to set it up. I would advise to have a look at the plugin handbook I linked to above. Also Using OOP plugin development is advised, a good starting point is Tom McFarlin tutorial on tutsplus: https://code.tutsplus.com/series/object-oriented-programming-in-wordpress--cms-699 .. and after that well worth looking at https://github.com/DevinVinson/WordPress-Plugin-Boilerplate and https://wppb.me/ hope that all helps.