-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathbaianada.php
101 lines (88 loc) · 2.46 KB
/
baianada.php
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
<?php
/**
* Plugin Name: Baianada
* Plugin URI:
* Description: Based project to create plugins for WordPress
* Author: leobaiano
* Author URI: http://leobaiano.com.br
* Version: 1.0.0
* License: GPLv2 or later
* Text Domain: lb-baianada
* Domain Path: /languages/
*/
if ( ! defined( 'ABSPATH' ) )
exit; // Exit if accessed directly.
// require_once 'autoloader.php';
/**
* Baianada
*
* @author Leo Baiano <[email protected]>
*/
class Baianada {
/**
* Instance of this class.
*
* @var object
*/
protected static $instance = null;
/**
* Slug.
*
* @var string
*/
protected static $text_domain = 'lb-baianada';
/**
* Initialize the plugin
*/
private function __construct() {
// Load plugin text domain
add_action( 'plugins_loaded', array( $this, 'load_plugin_textdomain' ) );
// Load styles and script
add_action( 'wp_enqueue_scripts', array( $this, 'load_admin_styles_and_scripts' ) );
// Load Helpers
add_action( 'init', array( $this, 'load_helper' ) );
}
/**
* Return an instance of this class.
*
* @return object A single instance of this class.
*/
public static function get_instance() {
// If the single instance hasn't been set, set it now.
if ( null == self::$instance ) {
self::$instance = new self;
}
return self::$instance;
}
/**
* Load the plugin text domain for translation.
*
* @return void
*/
public function load_plugin_textdomain() {
load_plugin_textdomain( self::$text_domain, false, dirname( plugin_basename( __FILE__ ) ) . '/languages/' );
}
/**
* Load styles and scripts
*
*/
public function load_admin_styles_and_scripts(){
wp_enqueue_style( self::$text_domain . '_css_main', plugins_url( '/assets/css/main.css', __FILE__ ), array(), null, 'all' );
$params = array(
'ajax_url' => admin_url( 'admin-ajax.php' )
);
wp_enqueue_script( self::$text_domain . '_js_main', plugins_url( '/assets/js/main.js', __FILE__ ), array( 'jquery' ), null, true );
wp_localize_script( self::$text_domain . '_js_main', 'data_brodinhos', $params );
}
/**
* Load auxiliary and third classes are in the class directory
*
*/
public function load_helper() {
$class_dir = plugin_dir_path( __FILE__ ) . "/helper/";
foreach ( glob( $class_dir . "*.php" ) as $filename ){
include $filename;
}
}
} // end class Baianada();
add_action( 'plugins_loaded', array( 'Baianada', 'get_instance' ), 0 );