Numerous wp-include files needed for simple php page - php

I am learning php in a sandbox. I have written a plugin and it works...till now.
So I am now wanting to save the options into the database and these settings are specific to the user so I am using:
update_user_meta
Well of course it said it needed user.php so after reading / learning how to include a file I added it. Well now it is dependat on plugin.php which has a dependency on functions.php which... so I'm up to four now. I must be doing something worng?
include(__DIR__.'/../wp-includes/functions.php');
include(__DIR__.'/../wp-includes/meta.php');
include(__DIR__.'/../wp-includes/plugin.php');
include(__DIR__.'/../wp-includes/user.php');
What I have is a plugin in the admin with a form for some settings. When button clicked form is posted to a php page for processing....it is this page (in wp-admin) that has the never ending include file list.
Is this to be expected or am I doing something wrong that these base wordpress libraries aren't available to my plugin?
TIA

The code in question should be within a plugin.
The core structure is:
/wp-content
/plugins
/mypluginname
/mypluginname.php
Then at the very least, mypluginname.php should contain the core code of the plugin, and any other php/wordpress logic you wish to have.
The plugin its self can be declared with the following:
/*
Plugin Name: Custom plugin
Plugin URI: http://domain.tld
Version: 1.0
Description: A custom plugin
Author: You
*/
Further, you can work around this and leverage core WP functions from external .php files that are not within the application by using require_once('/wp-load.php'); within your files. Note I do not recommend this method, it is just a direct answer to your question, but not the correct one.

Related

How can I successfully use a WordPress plugin to add styling to a website?

Some people are already styling their own websites, so is it possible
How do I get an html/css form to post to Gravity Forms?
Here is the link that also recognizes the problems that wordpress has, with users adding code, but it says if you download this plugin, your problems will be solved: Raw HTML plugin.
Here are the instructions from the website above:
To install the plugin follow these steps :
Download the raw-html.zip file to your local machine.
Go to ‘Plugins -> Add New -> Upload’.
Upload the zip file using the provided form.
Activate the plugin through the ‘Plugins’ menu in WordPress
Alternatively, you can search for “Raw HTML” in ‘Plugins -> Add New -> Search’ and install it from there, or unzip raw-html.zip and
upload the raw-html directory to your /wp-content/plugins directory.
I generally get to the point where I download the plugin (step 1, raw form) and then I am unable to proceed further. What should software I open the plugin with or do I need to go online (and where) to download the correct software?
Basically, I found out that certain software is required, not the plugin, to allow styling to the website. The link to access this feature is: how-to-use-plugin-not and she explains step by step. This thing type is for people using CSS, Bootstrap, HTML5, and JQuery. As far as I can see, no amount of research shows that a plugin is necessary but I was correct that certain preparatory steps were necessary. This is different than and unique from other methods of deeper coding.
Going to GitHub for an online portfolio would be more appropriate (shows your mastery more). This is according to Joshua Scott from free code camp but WordPress is great to develop CMS skills according to Jamie Schmidt, a developer for eight years.
The quick and dirty way that doesn't need any plugins or fiddling with the theme: throw your code into the content of the page you want it to appear on. Adding in the body is perfectly fine, and linking stylesheets outside of head works, even though it's not allowed in the specifications.
To do it the right way, you'll have to get your hands dirty and use a custom template file for the HTML and add your scripts and styles via wp_enqueue_script/wp_enqueue_style.

Visual Composer / WordPress - Edit Multiple Pages of the Same Template at Once

When using Visual Composer on WordPress, I am able to set up a template and then use that template for every page I build. HOWEVER, when I want to change something to pages using this template, I have to go back and edit each & every single page.
Is there a better way of doing this? Is there a way set up a global Visual Composer template that must abide by the latest configuration? Can it at least be hard coded into an existing PHP template so global changes can be made there?
That was a pain for years. One of the options now is to use WP ACF-VC Bridge plugin (http://wpacfvcbridge.com/). Here are the steps you need to take:
1) Create your page template as VC Snippet (here is a video overview http://wpacfvcbridge.com/vc-snippets/)
2) Set your static content with Visual Composer. You can also dynamically include data from your posts by using ACF Field Picker (here is an overview http://wpacfvcbridge.com/acf-field-picker/).
Note 1: Field context must be custom.
Note 2: these fields must be created with Advanced Custom Fields plugin (https://www.advancedcustomfields.com/pro/) which is included in WP ACF-VC Bridge. This is enough to cover 99% cases. If you'll need to include other post fields list post title or custom meta field, then you need to look for suitable Visual Composer add-on or write this custom shortcode.
3) Add VC Snippet to your post content with [vc-vc-snippet id="{VC Snippet Template Post ID}"]
If you have Visual Composer enabled for your post type (or you can enable it under Visual Composer -> Role Manager) you can use ready VC shortcode to embed VC Snippet.
Now if you'll change your VC Snippet, the changes will be immediately reflected across all posts.

How can identify that which blocks are calling on a particular content type in drupal

I have a website which is developed in drupal cms and i am newbie for drupal. I have setup whole website on my local host, and i'm debugging like that :
* Checked calling theme function,
* Checked activate theme page.tpl.php file
* Checked module which is called on content type.
But i can't get anything which become helpful for me. So please help me thanks in advance.
Drupal is known for having a pretty steep learning curve. Don't get discouraged when you are learning it!
To find out what template files and hooks are being called for specific blocks, regions, etc. of a theme, you can use the Devel and Theme Developer Modules (Theme Developer requires the simpleHtmlDom API Module):
Devel: https://www.drupal.org/project/devel
Theme Developer: https://www.drupal.org/project/devel
simpleHtmlDom API: https://www.drupal.org/project/simplehtmldom
Be wary of the version of simpleHtmlDom you install, Theme Developer only works with 7.x-1.12.
Once you've installed and enabled these modules, you will see a checkbox in the lower-left of each page. Upon checking said checkbox, you can then click any element on the page and an "info box" will be displayed with tons of debugging information:
In the sample I've included above, you can see that this element is defined in a function called theme_links(). One function name you can use to override in your theme is: minnelli_links (in this case, the theme used in this sample is "minnelli", hence minnelli_links() would override). The available variables to the function are also listed (this is where you are likely to find some information about the Content Type that is used to populate a block).
This is a great tool for debugging Drupal themes. Give it a try.
If blocks are placed on page from back-end 2 most common options are:
Placing a block on admin Blocks page (Structure -> Blocks). Here blocks can be placed to some regions, but in block properties some exceptions can be set, i.e. placing block only on some content type, or only for some user group or similar.
Blocks can be added with Context module - check if you have it running - Structure -> Context in admin menu.

Joomla 3 Flexicontent form custom plugin

After hours of googling and experimenting, I gave up :(
I need to add form to my articles in Joomla 3, that collects data from article's additional fields and emails them. Articles are managed by Flexicontent. Flexicontent overrides standard content manager so I tried to make a plugin inside 'content' plugins (later I tried 'flexicontent' as well). Basing on articles:
http://docs.joomla.org/Adding_custom_fields_to_the_article_component
http://betweenbrain.com/notes/72-fun-with-joomla-forms
https://github.com/joomla/joomla-cms/blob/master/plugins/user/profile/profile.php#L168
which all override some kind of form (user, content or contact).
I made my plugin folder, plugin php file, plugin manifest (xml file) and xmls with form fields. Then in my php file I wrote onContentPrepareForm(), as instructed. However, when I checked "$this" variable in my flexiconent template, there were no signs of any form. How should I place this form in my template?

How to override prestashop's default front-office template and controller in module

I want to override prestashop's default front-office template and controller in my newly created module without modifying prestashop's internal code/structure.
Example :
I have created one module i.e. "mymodule" in /modules folder where I want use prestashop's address form (address.tpl).
see : http://demo-store.prestashop.com/en/address.
I want to enhance address form by providing some additional fields/functionality but without changing prestashop's core functionality.
So, How can I override its controller/themes/templates in my module? I have searched lot of about this on google but didn't found anything :(
Any help would be appreciated.
Modules can work like you ask only if there's an HOOK inside the template/controller that allow you to run your customized function. Look if you have a chance of hooking your module somewhere by watching on the list showed inside
backoffice > modules > position
the Address controllers hasn't got any Hook if i recall well, so you have 3 ways to edit its functionality:
Go for an (imho) horrible client-side modification, by an heavy usage of jquery/ajax call to perform the action you need. Place the code by using a module that only add your js script in the header by using the hookHeader() function. Since this hook it's always called in all the site you can exploit the missing hook in the address template.
add yourself an hook inside the Controller and the template by following this procedure: http://www.prestashop.com/forums/topic/218291-create-custom-and-new-hook-in-ps-15/
use the amazing override features of the prestashop framework to modify what you need in the Controller file placed inside your prestashop_root/override/controllers/front/AddressController.php and inside your /prestashop_root/themes/my_theme/address.tpl. this way you can ovverride any function of the Controller withouth loosing the original functionality and if you'll need to upgrade your installation you will just need to check for the function you changed in the overrided file just as you would do for your module.

Categories