4. Why We Make Plugins?
Don’t touch WordPress core
5. What is a Plugin?
WordPress plugins are made up of PHP code and other
assets such as images, CSS, and JavaScript.
6. Getting Started
$ cd wp-content/plugins
$ mkdir plugin-name
$ touch plugin-name/plugin-name.php
wp-content/plugins/plugin-name/plugin-name.php
7. Readme file
=== Plugin Name ===
Contributors: (this should be a list of wordpress.org userid's)
Donate link: http://example.com/
Tags: comments, spam
Requires at least: 3.0.1
Tested up to: 3.4
Requires PHP: 5.2.4
Stable tag: 4.3
License: GPLv2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html
Here is a short description of the plugin.
8. Folder Structure
plugin-name
├── includes
│ ├── admin
│ │ ├── assets
│ │ │ └── Admin assets
│ │ └── Admin files
│ └── Core files
├── public
│ ├── assets
│ │ └── Front assets
│ └── Front files
└── languages
15. Check for Existing Implementations
PHP provides a number of functions to verify
the existence of variables, functions, classes,
and constants. All of these will return true if the
entity exists.
16. For variables: isset()
$data = $wpdb->get_row("SELECT * FROM mytable");
if (isset($data->name)) {
}
$option = get_option('your_option');
if (isset($option['status'])) {
}
Array Object
17. For functions: function_exists()
<?php
if (!function_exists('is_admin')) {
require_once(ABSPATH . 'wp-admin/includes/load.php');
}
if (!function_exists('post_exists')) {
require_once(ABSPATH . 'wp-admin/includes/post.php');
}
18. For classes: class_exists()
<?php
if (class_exists('WooCommerce')) {
// code that requires WooCommerce
} else {
// you don't appear to have WooCommerce activated
}
27. Shortcode
[audio], [caption], [embed], [gallery], [playlist], [video]
Shortcode is the best way to show the PHP
functions in the WordPress Editor and Widgets
28. Create a new Shortcode
function pn_show_users() {
echo date('Y-m-d');
}
// [pluginname-date]
function shortcode_function( $atts ) {
return pn_show_users();
}
add_shortcode( 'pluginname-date', 'shortcode_function' );
30. Enable i18n in your plugin
<?php
// Loading a Text Domain
load_plugin_textdomain( 'plugin-name', false, 'plugin-dir'
);
<h2><?php echo __( 'Your Ad here', 'plugin-name' ); ?></h2>
<h2><?php _e( 'Your Ad here', 'plugin-name' ); ?></h2>
31. Plugin Activation / Deactivation
Activation and deactivation hooks provide ways to perform actions when
plugins are activated or deactivated.
Add rewrite rules, add
custom database tables, or
set default option values.
Activation
Remove temporary data
such as cache, temp files and
directories.
Deactivation
32. Plugin Activation / Deactivation
<?php
register_activation_hook( __FILE__, 'pluginprefix_function_to_run' );
function pluginprefix_function_to_run() {
// Your code
}
register_deactivation_hook( __FILE__, 'pluginprefix_deactivation' );
function pluginprefix_deactivation() {
// Your code
}
33. Transients API (Cache)
Is a simple way of storing cached data in the
database temporary by giving it a custom name
and a timeframe after which it will expire and be
deleted.
34. Set / update the value in transient.
if ( false === ( $query_results = get_transient( 'special_query_results' ) ) ) {
$query_results = new WP_Query( 'cat=5&tag=tech&post_meta_key=featured' );
set_transient( 'special_query_results', $query_results, 12 * HOUR_IN_SECONDS );
}
// Use the data like you would have normally...
print_r($query_results);
38. Blocking direct access
<?php
defined( 'ABSPATH' ) or die( 'No script kiddies please!' );
// Your codes...
Prevent direct access provides a simple way to protect your
WordPress PHP files.
52. Focus on your support from day one
Because:
● Support is very expensive
● It can reduce your cost especially in future
● Learn more about your customers & the problem you want
to solve
53. Do we need to hire a support
person from day one?
NO!
54. ● Improve your support process
● Solve your support request before they are born
So, What should we do?
55. Step One: Set the Metrics
Good for start:
● Response Time
● Response Quality
56. Step Two: One Channel
If you have multiple channels of support, integrate them in a
central hub and grant access to your entire team to get an idea
of the latest issues and user's pains. One of the best services
for this is Slack!
Hello Everybody
I’m Mostafa from VeronaLabs, I’m very happy to be involved in this Meetup.
The first part of this presentation is related to Plugin Development and the second part is related to Customer Support which our experience in VeronaLabs.
VeronaLabs which over five hundred, thousand active users in Its products and provide high-quality services in WordPress, such as plugins development and custom services.
Well, I want explain to you about the plugin development.
Let's started
The first question is why we make plugins? This is a good question and the answer is…
Don't touch the WordPress core.
What is a Plugin?
WordPress plugins are made up of PHP code and other assets such as images, CSS, and JavaScript.
To make a new plugin, first you need to create a new file in this path.
Look at the path.
Readme file
The basic information of your plugin available in this file. you can specify some information such as Plugin Name, Contributors, Version, Requires PHP version and Tested version.
The readme file is required.
Folder Structure
There are many types of folder structure, and I think the structure is optional, It's better you using a standard structure.
Look at the slide, there are 3 main directory that have some items.
Suggestions
To develop the plugin you need to follow some simple rules. I want to tell you some of them.
Enable Debugging Mode
You can see all notice errors when developing. It recommended.
The constant of WP_DEBUG available in wp-config.php
Not to echo <script> and <style> tags directly
WordPress has useful functions for loading assets and you can use these functions. It’s very simple.
Look at the example.
Avoid Naming Collisions
It's better you use the namespace in your plugin, It's a good way to avoid naming conflicts in functions and classes name.
Take note of the example, there is a fatal error.
The namespace solve this problem.
Look at the example, It’s very simple.
Prefix Everything
The prefixes are used for functions, classes, and constants name, It's better to use the short name of your plugin for the prefixes.
Check for Existing Implementations
PHP provides a number of functions to verify the existence of variables, functions, classes, and constants. All of these will return true if the entity exists.
For variables, you can use the isset.
Look at the examples, the first example is for array and second is for the object
For functions, you can use function_exists.
Look at the examples.
For classes, you can use class_exists.
Look at the example.
For constants, you can use defined, sometimes you should set value for a constant if that doesn't have any value.
Conditional Loading
It's better you separate the codes in different environment. this method helps to your plugin to have better performance.
Hooks
There are 2 types of hooks in WordPress. Action and Filter
Let's get to know more with Hooks
Actions
Actions provide a way for running a function at a specific point in the execution of WordPress Core, plugins, and themes.
For example, you can send an email when a new item removed in your plugin.
Let's see the example.
In this example, we calling a action that send an email.
Filters
Filters provide a way for functions to modify data of other functions.
Let's see a real example.
Here we have a function that output is Sara.
Now we can change the output of this function by apply_filters, the final output will be Hello Sara
Plugin Features
I want to tell you about the main features of plugin.
Let's see that.
Shortcode
Shortcode is the best way to show the PHP functions in the WordPress Editor and Widgets
For example you can show a function output in the posts, pages or text widgets.
You should just have to add It.
Look at the example, It’s very easy.
Internationalization
Internationalization is the process of developing your plugin so it can easily be translated into other languages.
Internationalization helps to your plugin to grow up that. this is a fact.
To support Internationalization, only you need to add the text domain in the plugin, and then use these functions for load strings.
Activation and deactivation hooks provide ways to perform actions when plugins are activated or deactivated.
For activation you can add rewrite rules, add custom database tables, or set default option values.
And for Deactivation you can remove temporary data such as cache, temp files and directories.
Look at the example.
The first example is for activation and the second example is for deactivation.
Transients API (Cache)
Is a simple way of storing cached data in the database temporary by giving it a custom name and a timeframe after which it will expire and be deleted.
For example, you can cache your slow queries.
Let’s see an example.
In this example, we have a query that gets the feature posts and the result storing to cache. The query will be updated when cache expires.
Security Notes
Security is the most important point because your plugin will be installed on every WordPress.
Nonces
Nonces are generated numbers used to verify origin and intent of requests for security purposes. Each nonce can only be used once.
Here are 2 URLs with Nonces and without Nonces. Keep in mind after making the Nonce you should verify it.
Sanitizing User Data
WordPress has many useful functions for clearing user inputs.
With these functions, you can checks for invalid UTF-8, converts single less than characters to entity, strips all HTML tags and remove line breaks, tabs and extra white space.
Blocking direct access
Prevent direct access provides a simple way to protect your WordPress PHP files.
It’s recommended that you use this command above your PHP files.
Ignite
I have a gift for you. this is a starter plugin for development.
So let's know more about it.
Options Page
You can easily create the settings page with the tab.
All type of fields such as text, upload, WP editor and color available in the setting page.
Support Namespace
All classes have the namespace.
Clean Structure
The main structure of this plugin It's very simple.
Look at the file names and folders.
Installing and Creating Table
A simple example of creating a table in the database and display that in admin with WP_List_Table class.
Support REST API
A simple example to register endpoint for REST API.
Template Functions
You can put the theme functions in this file. It's very clean.
Let see your questions.
Hi everyone, my name is Navid Kashani, and I am Project Manager at Veronalabs. Today I want to talk about Customer Support.
Let's get started
Customer Support is a vast topic, and we can talk about it all day. However, since we have limited time, Today, I am only going to cover a small area that thought might be more practical for small and medium-sized software companies:
When hire your first customer support agent?
I think it’s a critical question because it can affect (have a significant impact on) your team and your product.
As you can see on this chart, in the early stages of each product, the founders are usually responsible for customer support. Also, as the product grows, the quality of customer support declines. However, you can solve this by hiring your first customer support agent. But keep it in mind that as the number of users grows the decline in the customer support quality is unavoidable.
I have seen many startups that the cost of their customer support has surpassed their other expenses.
Also, it can…
And with customer support, you can learn more ...
Because:
It increases your burn rate (cost/expenses) in the early days
You don’t understand your customer well enough and the problems that you want to solve
It creates a gap between your customers and your team. By hiring a customer support agent in the early days, your engineering team will be relieved from learning about the customer’s issues.
There are many ways to address this but on top of the list there are two main categories:One, by improving your support process
And two, by addressing your support requests before they are even generated.
These days, there are many support systems available with great data analytics where you can find many useful reports such as the response time, your busiest day, number of replies, and so on.
At VeronaLabs, we created a slack channel and integrated it with our help scout account, Github, and wp.org (RSS).
So, all the members of our team can see the users’ requests and problems on daily basis.
In the following slide, I will talk about how to reduce the support request by solving them before they are even generated.
Create a list of tags based on different stages of customer on boarding such as “installation”, “integration”, “feature request”, “can’t find something” and your product features. For example the report section, export functionality or user registration of your product.
Believe me, you will be surprised by the results.
One of the best ways to improve the user experience is, customer support, Analyzing the customer’s questions, problems and requests can give a great insight into how to improve an existing product or even create a new one.
WP-Statistics is our most popular plugin in VeronaLabs. One of the main reasons that make it so popular is that users can see all the data that they need in a simple dashboard and a single view without any weird filters or idioms. Let’s see...
You don’t have to learn something new nor you should read the documentation to understand what the metrics are.
I think you already know this view. It’s a screenshot from a Google Analytics page and in my opinion, one of the best tools in the world. In the past few years, we thought about adding more advanced features similar to Google Analytics. We always thought an excellent report page is a page like Google Analytics. However, our user has been telling us differently. Just think about what would happen if we spent a lot of time and energy building another Google Analytics: there probably wouldn't be a WP-statics today.
One of the services we have been using a lot recently for creating videos is Loom (useloom.com). If you haven’t used it already I highly recommend to check it out.
Back to our main question
As I mentioned before, not paying enough attention to this topic can increase the gap between your team and the users which can also cause an increase in your support budget and decline in the quality of your product in the future. And subsequently (later on) it will destroy your product and team.
This is a very important point in order to continue this process in the future. So your employee number one should not be just a simple customer support agent.
(Lets me check the questions)
Thank you so much for your time and I hope you have found this presentation useful.