-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwp-plugin.php
More file actions
44 lines (32 loc) · 1.2 KB
/
wp-plugin.php
File metadata and controls
44 lines (32 loc) · 1.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
<?php
/**
* Plugin Name: WP Plugin
* Plugin URI: https://github.com/shamsbd71/wp-plugin
* Description: Add a description of what your plugin does - this will be shown on the plugins admin page.
* Version: 1.0
Author: Abu Huraira
Author URI: https://github.com/shamsbd71
*/
// So let’s say you want to create a function for a call to action button, and then add it in multiple places in your theme.
// call it from your theme <?php wpmudev_cta(); >
function wpmudev_cta() {
$test = '<div class="cta">';
$test .= '<p>Call us on 000-0000 or email <a href="mailto:sales@example.com">sales@example.com</a></p>';
$test .= '</div>';
apply_filters( 'mytheme_cta', $test );
}
function wpmudev_cta_change() {
$test = '<p>Changed from Filter</p>';
apply_filters( 'mytheme_cta', $test );
}
add_action( 'mytheme_sidebar', 'wpmudev_cta' );
add_action( 'mytheme_below_content', 'wpmudev_cta' );
add_filter( 'mytheme_cta', 'wpmudev_cta_change' );
function wpmudev_cta_shortcode() {
ob_start(); ?>
<div class="cta">
<p>Call us on 000-0000 or email <a href="mailto:sales@example.com">sales@example.com</a></p>
</div>
<?php return ob_get_clean();
}
add_shortcode( 'CTA', 'wpmudev_cta_shortcode' );