admin.php
3 years ago
ai.php
3 years ago
answer.php
3 years ago
core.php
3 years ago
init.php
3 years ago
query.php
3 years ago
queryimage.php
3 years ago
querytext.php
3 years ago
rest.php
3 years ago
shortcodes.php
3 years ago
ui.php
3 years ago
ui.php
68 lines
| 1 | <?php |
| 2 | |
| 3 | class Meow_MWAI_UI { |
| 4 | private $core = null; |
| 5 | |
| 6 | function __construct( $core ) { |
| 7 | $this->core = $core; |
| 8 | add_action( 'admin_menu', array( $this, 'admin_menu' ) ); |
| 9 | add_filter( 'post_row_actions', [ $this, 'post_row_actions' ], 10, 2 ); |
| 10 | add_action( 'admin_footer', [ $this, 'admin_footer' ] ); |
| 11 | } |
| 12 | |
| 13 | function admin_menu() { |
| 14 | // Under Posts: |
| 15 | add_submenu_page( 'edit.php', 'Generate New', 'Generate New', 'manage_options', 'mwai_content_generator', |
| 16 | array( $this, 'ai_content_generator' ), 2 ); |
| 17 | add_management_page( 'AI Playground', __( 'AI Playground', 'ai-engine' ), 'manage_options', |
| 18 | 'mwai_dashboard', array( $this, 'ai_playground' ) ); |
| 19 | |
| 20 | // Under tools: |
| 21 | add_management_page( 'Content Generator', 'Content Generator', 'manage_options', 'mwai_content_generator', |
| 22 | array( $this, 'ai_content_generator' ) ); |
| 23 | add_management_page( 'Image Generator', 'Image Generator', 'manage_options', 'mwai_image_generator', |
| 24 | array( $this, 'ai_image_generator' ) ); |
| 25 | |
| 26 | // In the Admin Bar: |
| 27 | add_action( 'admin_bar_menu', array( $this, 'admin_bar_menu' ), 100 ); |
| 28 | } |
| 29 | |
| 30 | function admin_bar_menu( $wp_admin_bar ) { |
| 31 | $url = MWAI_URL . "/images/wand.png"; |
| 32 | $image_html = "<img style='height: 22px; margin-bottom: -5px; margin-right: 10px;' src='${url}' alt='UI Engine' />"; |
| 33 | |
| 34 | $args = array( |
| 35 | 'id' => 'mwai-playground', |
| 36 | 'title' => $image_html . __( 'AI Playground', 'ai-engine' ), |
| 37 | 'href' => admin_url( 'tools.php?page=mwai_dashboard' ), |
| 38 | 'meta' => array( 'class' => 'mwai-playground' ), |
| 39 | ); |
| 40 | $wp_admin_bar->add_node( $args ); |
| 41 | } |
| 42 | |
| 43 | public function ai_playground() { |
| 44 | echo '<div id="mwai-playground"></div>'; |
| 45 | } |
| 46 | |
| 47 | public function ai_content_generator() { |
| 48 | echo '<div id="mwai-content-generator"></div>'; |
| 49 | } |
| 50 | |
| 51 | public function ai_image_generator() { |
| 52 | echo '<div id="mwai-image-generator"></div>'; |
| 53 | } |
| 54 | |
| 55 | function post_row_actions( $actions, $post ) { |
| 56 | if ( $post->post_type === 'post' ) { |
| 57 | $actions['ai_titles'] = '<a class="mwai-link-title" href="#" data-id="' . |
| 58 | $post->ID . '" data-title="' . $post->post_title . '"> |
| 59 | <span class="dashicons dashicons-update"></span> Generate Titles</a>'; |
| 60 | } |
| 61 | return $actions; |
| 62 | } |
| 63 | |
| 64 | function admin_footer() { |
| 65 | echo '<div id="mwai-admin-postsList"></div>'; |
| 66 | } |
| 67 | } |
| 68 |