classes
9 years ago
metaboxes
9 years ago
modules
9 years ago
admin-hooks.php
9 years ago
admin-the-functions.php
9 years ago
index.php
9 years ago
admin-hooks.php
178 lines
| 1 | <?php |
| 2 | |
| 3 | |
| 4 | |
| 5 | |
| 6 | /*-----------------------------------------------------------------------------------*/ |
| 7 | /* Add shortcode button to tinymce |
| 8 | /*-----------------------------------------------------------------------------------*/ |
| 9 | |
| 10 | function auxin_register_shortcode_button( $buttons ) { |
| 11 | array_push( $buttons, '|', 'phlox_shortcodes_button' ); |
| 12 | return $buttons; |
| 13 | } |
| 14 | |
| 15 | /** |
| 16 | * Add the shortcode button to TinyMCE |
| 17 | * |
| 18 | * @param array $plugin_array |
| 19 | * @return array |
| 20 | */ |
| 21 | function auxin_add_elements_tinymce_plugin( $plugin_array ) { |
| 22 | $wp_version = get_bloginfo( 'version' ); |
| 23 | |
| 24 | $plugin_array['phlox_shortcodes_button'] = AUXELS_ADMIN_URL."/assets/js/tinymce/plugins/auxin-btns.js"; |
| 25 | |
| 26 | return $plugin_array; |
| 27 | } |
| 28 | |
| 29 | |
| 30 | function axion_init_shortcode_manager(){ |
| 31 | if ( ! current_user_can('edit_posts') && ! current_user_can('edit_pages') ) |
| 32 | return; |
| 33 | |
| 34 | add_filter( 'mce_external_plugins', 'auxin_add_elements_tinymce_plugin' ); |
| 35 | add_filter( 'mce_buttons', 'auxin_register_shortcode_button' ); |
| 36 | } |
| 37 | add_action("init", "axion_init_shortcode_manager"); |
| 38 | |
| 39 | /*-----------------------------------------------------------------------------------*/ |
| 40 | /* Add Editor styles |
| 41 | /*-----------------------------------------------------------------------------------*/ |
| 42 | |
| 43 | function auxin_register_mce_buttons_style(){ |
| 44 | wp_register_style('auxin_mce_buttons' , AUXELS_ADMIN_URL. '/assets/css/editor.css', NULL, '1.1'); |
| 45 | wp_enqueue_style('auxin_mce_buttons'); |
| 46 | } |
| 47 | add_action('admin_enqueue_scripts', 'auxin_register_mce_buttons_style'); |
| 48 | |
| 49 | |
| 50 | |
| 51 | /*-----------------------------------------------------------------------------------*/ |
| 52 | /* Adds system status tab in theme about (welcome) page |
| 53 | /*-----------------------------------------------------------------------------------*/ |
| 54 | |
| 55 | function auxin_about_system_status( $sections ){ |
| 56 | |
| 57 | $sections['status'] = array( |
| 58 | 'label' => __( 'System Status', 'auxin-elements' ), |
| 59 | 'description' => __( 'The informaition about your WordPress installation which can be helpful for debugging or monitoring your website.', 'auxin-elements'), |
| 60 | 'callback' => 'auxin_get_about_system_status' |
| 61 | ); |
| 62 | |
| 63 | return $sections; |
| 64 | } |
| 65 | |
| 66 | add_filter( 'auxin_admin_welcome_sections', 'auxin_about_system_status', 100 ); |
| 67 | |
| 68 | |
| 69 | |
| 70 | /*-----------------------------------------------------------------------------------*/ |
| 71 | /* Adds subtitle meta field to 'Title setting' tab |
| 72 | /*-----------------------------------------------------------------------------------*/ |
| 73 | |
| 74 | function auxin_add_metabox_field_to_title_setting_tab( $fields, $id, $type ){ |
| 75 | |
| 76 | if( 'general-title' == $id ){ |
| 77 | array_unshift( |
| 78 | $fields, |
| 79 | array( |
| 80 | 'title' => __('Subtitle', THEME_DOMAIN), |
| 81 | 'description' => __('Second Title (optional). Note: You have to enable "Display Title Bar Section" option in order to display the subtitle.', THEME_DOMAIN), |
| 82 | 'id' => 'page_subtitle', |
| 83 | 'type' => 'editor', |
| 84 | 'default' => '' |
| 85 | ) |
| 86 | ); |
| 87 | } |
| 88 | |
| 89 | return $fields; |
| 90 | } |
| 91 | add_filter( 'auxin_metabox_fields', 'auxin_add_metabox_field_to_title_setting_tab', 10, 3 ); |
| 92 | |
| 93 | |
| 94 | /*-----------------------------------------------------------------------------------*/ |
| 95 | /* Adds Custom JavaScript meta field to 'Advanced setting' tab |
| 96 | /*-----------------------------------------------------------------------------------*/ |
| 97 | |
| 98 | function auxin_add_metabox_field_to_advanced_setting_tab( $fields, $id, $type ){ |
| 99 | |
| 100 | if( 'general-advanced' == $id ){ |
| 101 | $fields[] = array( |
| 102 | 'title' => __('Custom JavaScript Code', THEME_DOMAIN), |
| 103 | 'description' => __('Attention: The following custom JavaScript code will be applied ONLY to this page.', THEME_DOMAIN).'<br />'. |
| 104 | __('For defining global JavaScript roles, please use custom javaScript field on option panel.', THEME_DOMAIN ), |
| 105 | 'id' => 'aux_page_custom_js', |
| 106 | 'type' => 'code', |
| 107 | 'mode' => 'javascript', |
| 108 | 'default' => '' |
| 109 | ); |
| 110 | } |
| 111 | return $fields; |
| 112 | } |
| 113 | add_filter( 'auxin_metabox_fields', 'auxin_add_metabox_field_to_advanced_setting_tab', 10, 3 ); |
| 114 | |
| 115 | |
| 116 | |
| 117 | |
| 118 | |
| 119 | |
| 120 | /*======================================================================*/ |
| 121 | |
| 122 | function auxin_elements_add_post_metabox_models( $models ){ |
| 123 | |
| 124 | // Load general metabox models |
| 125 | include_once( 'metaboxes/metabox-fields-post-audio.php' ); |
| 126 | include_once( 'metaboxes/metabox-fields-post-gallery.php' ); |
| 127 | include_once( 'metaboxes/metabox-fields-post-quote.php' ); |
| 128 | include_once( 'metaboxes/metabox-fields-post-video.php' ); |
| 129 | |
| 130 | $models[] = array( |
| 131 | 'model' => auxin_metabox_fields_post_gallery(), |
| 132 | 'priority' => 20 |
| 133 | ); |
| 134 | |
| 135 | $models[] = array( |
| 136 | 'model' => auxin_metabox_fields_post_video(), |
| 137 | 'priority' => 22 |
| 138 | ); |
| 139 | |
| 140 | $models[] = array( |
| 141 | 'model' => auxin_metabox_fields_post_audio(), |
| 142 | 'priority' => 24 |
| 143 | ); |
| 144 | |
| 145 | $models[] = array( |
| 146 | 'model' => auxin_metabox_fields_post_quote(), |
| 147 | 'priority' => 26 |
| 148 | ); |
| 149 | |
| 150 | return $models; |
| 151 | } |
| 152 | |
| 153 | add_filter( 'auxin_admin_metabox_models_post', 'auxin_elements_add_post_metabox_models' ); |
| 154 | |
| 155 | |
| 156 | /*-----------------------------------------------------------------------------------*/ |
| 157 | /* Add theme tab in siteorigin page builder |
| 158 | /*-----------------------------------------------------------------------------------*/ |
| 159 | |
| 160 | function auxin_add_widget_tabs($tabs) { |
| 161 | $tabs[] = array( |
| 162 | 'title' => THEME_NAME, |
| 163 | 'filter' => array( |
| 164 | 'groups' => array('auxin') |
| 165 | ) |
| 166 | ); |
| 167 | |
| 168 | if (isset($tabs['recommended'])){ |
| 169 | unset($tabs['recommended']); |
| 170 | } |
| 171 | |
| 172 | |
| 173 | return $tabs; |
| 174 | } |
| 175 | add_filter( 'siteorigin_panels_widget_dialog_tabs', 'auxin_add_widget_tabs', 20 ); |
| 176 | |
| 177 | // ============================================================================= |
| 178 |