admin.php
3 years ago
core.php
3 years ago
init.php
3 years ago
openai.php
3 years ago
rest.php
3 years ago
ui.php
3 years ago
ui.php
49 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 | add_management_page( 'AI Playground', __( 'AI Playground', 'ai-engine' ), 'manage_options', |
| 15 | 'mwai_dashboard', array( $this, 'ai_playground' ) ); |
| 16 | add_action( 'admin_bar_menu', array( $this, 'admin_bar_menu' ), 100 ); |
| 17 | } |
| 18 | |
| 19 | function admin_bar_menu( $wp_admin_bar ) { |
| 20 | $url = MWAI_URL . "/images/wand.png"; |
| 21 | $image_html = "<img style='height: 22px; margin-bottom: -5px; margin-right: 10px;' src='${url}' alt='UI Engine' />"; |
| 22 | |
| 23 | $args = array( |
| 24 | 'id' => 'mwai-playground', |
| 25 | 'title' => $image_html . __( 'AI Playground', 'ai-engine' ), |
| 26 | 'href' => admin_url( 'tools.php?page=mwai_dashboard' ), |
| 27 | 'meta' => array( 'class' => 'mwai-playground' ), |
| 28 | ); |
| 29 | $wp_admin_bar->add_node( $args ); |
| 30 | } |
| 31 | |
| 32 | public function ai_playground() { |
| 33 | echo '<div id="mwai-playground"></div>'; |
| 34 | } |
| 35 | |
| 36 | function post_row_actions( $actions, $post ) { |
| 37 | if ( $post->post_type === 'post' ) { |
| 38 | $actions['ai_titles'] = '<a class="mwai-link-title" href="#" data-id="' . |
| 39 | $post->ID . '" data-title="' . $post->post_title . '"> |
| 40 | <span class="dashicons dashicons-update"></span> Generate Titles</a>'; |
| 41 | } |
| 42 | return $actions; |
| 43 | } |
| 44 | |
| 45 | function admin_footer() { |
| 46 | echo '<div id="mwai-admin-postsList"></div>'; |
| 47 | } |
| 48 | } |
| 49 |