How would WP plugins need to be recoded in order to work on Modx? - wordpress

Lets say, I want an affiliate plugin that I bought for WP to work on Modx. What are the procedures to follow? Yes, you can assume that all the plugins I bought use php, javascript, and jquery.

You need to refactoring your plugin to modx snippets and chunks - http://www.cmslesstraveled.com/index/tutorials/refactoring-a-simple-php-application-for-modx.html

You can use internal Wordpress functions by including this file
include_once($_SERVER['DOCUMENT_ROOT'].'/wp-load.php' );
You can try including the file in one of your modx templates and then
see if it gives you access to your affiliate plugin functions.
Vice-Versa you could include modx into your wordpress theme files by
adding this code.
define('MODX_CORE_PATH', 'full/path/to/your/modx/core/');
define('MODX_CONFIG_KEY', 'config'); require_once MODX_CORE_PATH .
'model/modx/modx.class.php'; $modx= new modX();
$modx->initialize('mgr');
This will give you access to the $modx object and all it's wonders.
Source: http://www.quora.com/MODX-CMS/How-would-WordPress-plugins-need-to-be-recoded-in-order-to-work-in-MODX

Related

Drupal 7 block.tpl.php does not exist

I am new in Drupal and try to create my own Drupal theme. I have copied the Garland theme from theme/garland and pasted it to sites/all/themes/(renamed mytheme). But when I search on how to integrate templates in Drupal, there I got that I need four mandatory files: comment.tpl.php, page.tpl.php, node.tpl.php and block.tpl.php but in that theme there is no file name called block.tpl.php, inspite I have a template.php.
Please guide me on this, do I need to create block.tpl.php by myself?? If I create it what would be its content and how do I use that, also what is the use of template.php in my site.
I am new in this CMS (Drupal) so any response would be appreciable and helpful for me.
You can create your own block.tpl.php by copying it form modules/block to your theme's folder (remember to clear the cache!). template.php should contain custom overrides to the theme functions, as well as implementations of process/preprocess hooks. You can find an in-depth discussion about how Drupal's theme system work by following this link and in general by searching drupal.org website.

Including plugins in your wordpress theme?

I am developing a WordPress theme, i have downloaded and installed the "contact form 7" plugin. Now when i send this theme to my client and they install/activate the theme, i would like the "contact form 7" plugin to be included.
I haven't got access to their wp-admin and i can't expect them to manually install the plugins. So to make it easier for them, i'd like to package the plugins with the theme. Then they install and everything works correctly.
How do i do this or is there a better way e.g. recommend installing a plugin?
You will want to use some variant of the following:
function my_activate_theme() {
$plugins = array(
"plugin_name_1",
"plugin_name_2",
"etc..."
);
foreach ($plugins as $plugin) {
$path = '/path/to/wordpress/wp-content/plugins/{$plugin}.php';
activate_plugin($path);
}
}
add_action('switch_theme', 'my_activate_themes');
You will have to fiddle around with my code, as I don't have access to a wordpress install at the moment to test on, but basically the idea is that you throw this into your functions.php file. It registers the hook for switching theme and on theme switch, loops through the specified plugins and activates them.
I hope this helps, if not, please give me more information and I will attempt to provide further guidance. Good luck!
If you are currently developing theme, you'd rather use tgm activation code than including plugins into your theme.
Please review this Wordpress Theme.
This theme use tgm activation code to install "Visual Composer","Layerslider","Revslider","Quickshop" plugins.
It's much easier to customize and has lots of features. Also easy to learn code tips.
Regards. HanaTheme.

Can my WordPress custom templates be in the plugin folder or only in the theme folder?

A WordPress theme I am developing has an integrated custom post type called "albums" which utilizes a few custom templates (archive-albums.php, content-albums.php, etc.). What I want to do is transfer this functionality, along with the template files, into a plugin for the sake of portability.
I transferred the CPT code from the functions.php with success, but when I try to move the template files from the theme folder to the plugin folder, things fall apart. I feel like it should be simple to somehow register the templates so WordPress knows to load them.
Can my WordPress custom templates be in plugin folder or only theme folder?
Things are falling apart because when you move those files, you're violating WP's native template hierarchy. You'll need to explicitly declare the location of those files. Using the archive as an example, you could add something like this to functions.php (to tell WP to look elsewhere):
add_filter('template_include', 'include_album_template', 1);
function include_album_template($template_path) {
if(get_post_type() == 'albums') {
if(!is_single()) {
$theme_file = 'path-to-your-plugin-directory';
$template_path = $theme_file;
}
}
return $template_path;
}
Obviously you'd use your own path, and I wrote this hastily so you might want to refactor.
I have the same issue. I'm already using add_filter ('template_include', ...) problem is that I need to specify a file to return, and in this case being it,index.php. This raises an issue with the theme not running entirely as if installed via themes folder, because what I need is to have WP selecting the appropriate file to render without any conditional logic from my part. So if it is a post it will select the single.php and so on. Another problem raised with this method is that in header.php the call get_header (); ignores the local file header.php and loads the default theme installed file instead.

Wordpress 3 Multisite with same Medialibrary

i created a Worpress 3 Multisite with 5 Sub-Blogs.
Is it possible to share the same Media-Library in this Blogs?
i changed upload_path in wp_1_options and wp_2_options for example and also in my backend in "Super Admins" Menu but it has no effect.
The files are uploaded to wp_contents/blogs.dir/1-2-3/files and the options have no effect.
any ideas? thanks!
One way around is to hook onto the load events of all media admin files, and switch to the main blog using switch_to_blog(1).
This would mean in any blog admin, the media library will always run as if it were on the main blog.
Note that a couple caveats include;
The media library for all blogs is stored in the main blog database table.
You may run into problems with inserting media into posts outside the main blog admin
You will run into problems with inserting galleries into posts outside the main blog admin
User permissions may be false positives or negatives
My best advice would be to use the code example below, and have a good play around with blog admins, logged in as different users, with different roles, and see what happens.
function use_main_blog_library()
{
switch_to_blog(1);
}
add_action('load-media-new.php', 'use_main_blog_library');
add_action('load-media-upload.php', 'use_main_blog_library');
add_action('load-media.php', 'use_main_blog_library');
add_action('load-upload.php', 'use_main_blog_library');
In my searching on this topic, several posts lead back to this one, so I figured I'd share an idea that might help someone wanting to develop a suitable plugin to solve this...
Use get_site_option() and update_site_option() to store global plugin options.
Add an option via hooks to choose if a media upload should be shared network-wide and let the plugin track which media files and where they're located at.
Again, using hooks, have the shared items show up in each blog's media library and perhaps add an indicator showing the file is a network share.
I have spent several hours playing with the administrator hooks and filters and this could be accomplished through them, although I'm not savvy enough to know how to fully integrate it with all of the media library features.
The Shiba Media Library Plugin could serve as a valuable reference since they have utilized several custom features for the Media Library via hooks and filters.
I really wish I had the spare time to work on this right now because I would take my best shot at it. I hope this helps someone else.
I have found a possible solution, which works for me in WP3.7.1 (I haven't tested it in earlier versions)
Create a filter, which overrides the default upload directories:
add_filter('upload_dir', 'ms_global_upload_dir');
function ms_global_upload_dir($uploads)
{
$ms_dir = '/sites/' . get_current_blog_id();
$uploads['path'] = str_replace($ms_dir, "", $uploads['path']);
$uploads['url'] = str_replace($ms_dir, "", $uploads['url']);
$uploads['basedir'] = str_replace($ms_dir, "", $uploads['basedir']);
$uploads['baseurl'] = str_replace($ms_dir, "", $uploads['baseurl']);
return $uploads;
}
Important: the 'Upload Url Path' settings should be empty in Site Settings or if you need to customize it, check the results by dumping the $uploads array to view possible conflicts.
To check if your version of WP supports this method, locate function wp_upload_dir() in file wp-includes/functions.php and find function call: $uploads = apply_filters( 'upload_dir' ...
If it presents, the solution above should work.
Hope, this helps ...
Additionally, I have spent almost two days to make a solution to replicate/delete the uploaded media in each of the blogs with action hooks 'add_attachment' and 'delete_attachment' by generating the necessary post and postmeta entries in the corresponding database tables. With this, you can add/delete media in any of the blogs, that will be visible in/removed from all blogs media library. If you are interested, I can share it...
Cheers

Can I use a wordpress theme in new php pages?

I'm putting together a web site that needed to include some signup and blogging capability. Wordpress seems to be a perfect fit for that portion of the app, so I've started experimenting with it. I see plenty of tutorials on creating custom themes so I don't expect that to be a problem.
What I'm not able to figure out is what to do with the rest of my site. I will have other non-blogging related php pages that will access a database, etc. I see that wordpress has a capability for generic pages of static content, but these would need to be coded PHP pages. I just can't find a way of having the wordpress theme apply to other php pages outside of wordpress. I was hoping of just doing something like
wp_header();
blah blah
wp_sidebar();
blah blah
wp_footer();
but I'm not really seeing any examples or documentation on how this might be done. Am I missing a key piece of documentation?
EDIT: The answer is to essentially copy and paste a file from the theme, with one crucial addition:
require( dirname(__FILE__) . 'path_to_wp_root/wp-load.php');
That sets up the wordpress environment and allows me to call get_header(), get_sidebar(), get_footer(), etc.
Generally, "yes".
A well-designed WordPress theme uses mostly CSS/Stylesheets for display, and you are correct in your assumptions: Look through the "Codex" about Theme Design / Template Design (http://codex.wordpress.org/Stepping_Into_Templates).
Essentially you could base your design on some of the current theme files, but leave out "the loop".
I think what you really want to do is include wp-load.php at the top of your php file. This will give you access to all the wordpress functions (wp-header(), wp-footer(), etc).
wordpress has pages in it. each page can have its own content and its own template and still be part of the whole wordpress site. i mean it will share the header and the footer if you want and will share the css and javascript that you include in both.
for more information on pages and pages templates
What you should do is develop your other non-blogging related php pages as a wordpress plugin. There are plenty of references online on how to do this, for example:
http://www.tutorialized.com/view/tutorial/Creating-a-Custom-Wordpress-Plugin-from-Scratch/41834
Another option is to use Wordpress as the CMS for all content on your site. This is increasingly becoming popular, as Wordpress is quite good at non-blog-things these days.
define('STYLESHEETPATH', '');
define('TEMPLATEPATH', '');
$base = substr(__DIR__, 0,strrpos(__DIR__, '/[name of the dir where u store the php files]'));
require_once($base."/wp-load.php");
require_once($base."/wp-includes/pluggable.php");
easy to use wordpress function outside

Resources