RTMediaAdmin::add_dashboard_widgets PHP Method

add_dashboard_widgets() public method

Create the function use in the action hook
public add_dashboard_widgets ( ) : void
return void
        public function add_dashboard_widgets()
        {
            wp_add_dashboard_widget('rtmedia_dashboard_widget', esc_html__('Right Now in rtMedia', 'buddypress-media'), array(&$this, 'rtmedia_dashboard_widget_function'));
            global $wp_meta_boxes;
            // Get the regular dashboard widgets array
            // (which has our new widget already but at the end)
            $normal_dashboard = $wp_meta_boxes['dashboard']['normal']['core'];
            // Backup and delete our new dashboard widget from the end of the array
            $example_widget_backup = array('rtmedia_dashboard_widget' => $normal_dashboard['rtmedia_dashboard_widget']);
            unset($normal_dashboard['rtmedia_dashboard_widget']);
            // Merge the two arrays together so our widget is at the beginning
            $sorted_dashboard = array_merge($example_widget_backup, $normal_dashboard);
            // Save the sorted array back into the original metaboxes
            $wp_meta_boxes['dashboard']['normal']['core'] = $sorted_dashboard;
        }