PluginProbe
Ultimate WP Mail / trunk
Ultimate WP Mail vtrunk
1.3.13 1.3.12 trunk 0.11 0.25 1.0.0 1.0.1 1.0.10 1.0.11 1.0.12 1.0.13 1.0.14 1.0.15 1.0.16 1.0.17 1.0.18 1.0.2 1.0.3 1.0.4 1.0.5 1.0.6 1.0.7 1.0.8 1.0.9 1.1.0 All 46 releases
ultimate-wp-mail / includes / CustomElementManager.class.php

CustomElementManager.class.php in Ultimate WP Mail trunk, at includes/CustomElementManager.class.php

112 lines 2.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Class to handle all custom element management for the Ultimate WP Mail plugin
4 */
5
6 if ( !defined( 'ABSPATH' ) )
7 exit;
8
9 if ( !class_exists( 'ewduwpmCustomElementManager' ) ) {
10 class ewduwpmCustomElementManager {
11
12 // Array all registered custom element sections
13 public $custom_element_sections = array();
14
15 // Array all registered custom elements
16 public $custom_elements = array();
17
18 public function __construct() {
19
20 add_action( 'init', array( $this, 'allow_custom_element_registration' ), 11 );
21 }
22
23 /**
24 * Allow third party add-ons to hook in to register their own elements
25 * @since 1.0.0
26 */
27 public function allow_custom_element_registration() {
28
29 do_action( 'uwpm_register_custom_element_section' );
30 do_action( 'uwpm_register_custom_element' );
31 }
32
33 /**
34 * Add a custom element to the registered elements array
35 * @since 1.0.0
36 */
37 public function register_custom_element_section( $custom_element_section ) {
38
39 if ( get_class( $custom_element_section ) != 'UWPM_Element_Section' ) { return; }
40
41 $this->custom_element_sections[] = $custom_element_section;
42 }
43
44 /**
45 * Add a custom element to the registered elements array
46 * @since 1.0.0
47 */
48 public function register_custom_element( $custom_element ) {
49
50 if ( get_class( $custom_element ) != 'UWPM_Element' ) { return; }
51
52 $this->custom_elements[] = $custom_element;
53 }
54
55 /**
56 * Return an array of all the registered sections
57 * @since 1.0.0
58 */
59 public function get_custom_element_sections() {
60
61 $sections = array();
62
63 foreach ( $this->custom_element_sections as $custom_element_section ) {
64
65 $section = array(
66 'slug' => $custom_element_section->slug,
67 'name' => $custom_element_section->label
68 );
69
70 $sections[] = $section;
71 }
72
73 return $sections;
74 }
75
76 /**
77 * Returns all of the registered elements
78 * @since 1.0.0
79 */
80 public function get_custom_elements() {
81
82 return $this->custom_elements;
83 }
84
85 /**
86 * Returns all of the default user fields
87 * @since 1.0.0
88 */
89 public function get_user_fields() {
90
91 $contact_methods = wp_get_user_contact_methods();
92
93 $user_fields = array(
94 array( 'slug' => 'username', 'name' => 'Username' ),
95 array( 'slug' => 'fname', 'name' => 'First Name' ),
96 array( 'slug' => 'lname', 'name' => 'Last Name' ),
97 array( 'slug' => 'nickname', 'name' => 'Nickname' ),
98 array( 'slug' => 'dname', 'name' => 'Display Name' ),
99 array( 'slug' => 'email', 'name' => 'Email' ),
100 array( 'slug' => 'website', 'name' => 'Website' )
101 );
102
103 foreach ( $contact_methods as $key => $contact_method ) {
104
105 $user_fields[] = array( 'slug' => $key, 'name' => $contact_method );
106 }
107
108 return $user_fields;
109 }
110
111 }
112 }