| 1 |
<?php |
| 2 |
/** |
| 3 |
* This class is implemented page: import, export in the admin panel. |
| 4 |
* |
| 5 |
* @author Alex Kovalev <alex.kovalevv@gmail.com> |
| 6 |
* @since 1.0.0 |
| 7 |
* @package core |
| 8 |
* @copyright (c) 2018, OnePress Ltd |
| 9 |
* s |
| 10 |
*/ |
| 11 |
|
| 12 |
// Exit if accessed directly |
| 13 |
if ( ! defined( 'ABSPATH' ) ) { |
| 14 |
exit; |
| 15 |
} |
| 16 |
|
| 17 |
/** |
| 18 |
* Common Settings |
| 19 |
*/ |
| 20 |
class WINP_NewItemPage extends WINP_Page { |
| 21 |
|
| 22 |
/** |
| 23 |
* @param Wbcr_Factory422_Plugin $plugin |
| 24 |
*/ |
| 25 |
public function __construct( Wbcr_Factory422_Plugin $plugin ) { |
| 26 |
$this->menu_post_type = WINP_SNIPPETS_POST_TYPE; |
| 27 |
|
| 28 |
$this->menu_position = 1; |
| 29 |
$this->id = "new-item"; |
| 30 |
$this->menu_title = __( '+ Add snippet', 'insert-php' ); |
| 31 |
|
| 32 |
parent::__construct( $plugin ); |
| 33 |
|
| 34 |
$this->plugin = $plugin; |
| 35 |
} |
| 36 |
|
| 37 |
public function assets( $scripts, $styles ) { |
| 38 |
$this->scripts->request( 'jquery' ); |
| 39 |
|
| 40 |
$this->styles->request( [ |
| 41 |
'bootstrap.core' |
| 42 |
], 'bootstrap' ); |
| 43 |
|
| 44 |
//$this->scripts->add( WINP_PLUGIN_URL . '/admin/assets/js/new-item.js' ); |
| 45 |
$this->styles->add( WINP_PLUGIN_URL . '/admin/assets/css/new-item.css' ); |
| 46 |
} |
| 47 |
|
| 48 |
/** |
| 49 |
* Prints the contents of the page. |
| 50 |
*/ |
| 51 |
public function indexAction() { |
| 52 |
$types = [ |
| 53 |
WINP_SNIPPET_TYPE_PHP => [ |
| 54 |
'title' => __( 'PHP snippet', 'insert-php' ), |
| 55 |
'help' => WINP_Plugin::app()->get_support()->get_tracking_page_url( 'getting-started-with-woody-ad-snippets/#Creating_a_PHP_snippet', 'create-snippet' ), |
| 56 |
'description' => '<p>' . __( 'Used for inserting php code. Can be used for registering functions, hooks, global variables, printing text. Virtual functions.php', 'insert-php' ) . '</p>' |
| 57 |
], |
| 58 |
WINP_SNIPPET_TYPE_TEXT => [ |
| 59 |
'title' => __( 'Text snippet', 'insert-php' ), |
| 60 |
'help' => WINP_Plugin::app()->get_support()->get_tracking_page_url( 'getting-started-with-woody-ad-snippets/#Creating_a_Text_Snippet', 'create-snippet' ), |
| 61 |
'description' => '<p>' . __( 'Used for inserting formatted text. Can be used for inserting quotes, paragraphs, shortcodes from other plugins, tables, media files.', 'insert-php' ) . '</p>' |
| 62 |
], |
| 63 |
WINP_SNIPPET_TYPE_UNIVERSAL => [ |
| 64 |
'title' => __( 'Universal snippet', 'insert-php' ), |
| 65 |
'help' => WINP_Plugin::app()->get_support()->get_tracking_page_url( 'getting-started-with-woody-ad-snippets/#Creating_a_Universal_Snippet', 'create-snippet' ), |
| 66 |
'description' => '<p>' . __( 'Used for inserting php, html, js & css code. Can be used for inserting ads, analytics, embeds & other complex scenarios.', 'insert-php' ) . '</p>' |
| 67 |
], |
| 68 |
WINP_SNIPPET_TYPE_CSS => [ |
| 69 |
'title' => __( 'Css snippet', 'insert-php' ), |
| 70 |
'help' => '#', |
| 71 |
'description' => '<p>' . __( 'Used for inserting css code. Can be used for inserting css styles.', 'insert-php' ) . '</p>' |
| 72 |
], |
| 73 |
WINP_SNIPPET_TYPE_JS => [ |
| 74 |
'title' => __( 'JavaScript snippet', 'insert-php' ), |
| 75 |
'help' => '#', |
| 76 |
'description' => '<p>' . __( 'Used for inserting js code. Can be used for inserting ads, analytics, embeds & other complex scenarios.', 'insert-php' ) . '</p>' |
| 77 |
], |
| 78 |
WINP_SNIPPET_TYPE_HTML => [ |
| 79 |
'title' => __( 'HTML snippet', 'insert-php' ), |
| 80 |
'help' => '#', |
| 81 |
'description' => '<p>' . __( 'Used for inserting html code. Can be used for inserting html code.', 'insert-php' ) . '</p>' |
| 82 |
], |
| 83 |
]; ?> |
| 84 |
<div class="wrap <?php echo WINP_Helper::get_factory_class(); ?>"> |
| 85 |
<div class="wbcr-inp-items"> |
| 86 |
<h2><?php _e( 'Creating New Snippet', 'insert-php' ) ?></h2> |
| 87 |
<p style="margin-top: 0;"><?php _e( 'Choose which snippet you would like to create.', 'insert-php' ) ?></p> |
| 88 |
<?php foreach ( $types as $name => $type ) { ?> |
| 89 |
<div class="postbox wbcr-inp-item"> |
| 90 |
<h4 class="wbcr-inp-title"> |
| 91 |
<?php echo $type['title'] ?> |
| 92 |
</h4> |
| 93 |
<div class="wbcr-inp-description"> |
| 94 |
<?php echo $type['description'] ?> |
| 95 |
</div> |
| 96 |
<div class="wbcr-inp-buttons"> |
| 97 |
<a href="<?php echo admin_url( 'post-new.php?post_type=' . WINP_SNIPPETS_POST_TYPE . '&winp_item=' . $name ); ?>" |
| 98 |
class="button button-large wbcr-inp-create"> |
| 99 |
<span class="dashicons dashicons-plus"></span><span><?php _e( 'Create Item', 'insert-php' ) ?></span> |
| 100 |
</a> |
| 101 |
<?php if ( isset( $type['help'] ) ) { ?> |
| 102 |
<a href="<?php echo $type['help'] ?>" class="button button-large wbcr-inp-hint-button" target="_blank" rel="noopener" title="<?php _e( 'Click here to learn more', 'insert-php' ) ?>"> |
| 103 |
<span class="dashicons dashicons-editor-help"></span> |
| 104 |
</a> |
| 105 |
<?php } ?> |
| 106 |
</div> |
| 107 |
</div> |
| 108 |
<?php } ?> |
| 109 |
</div> |
| 110 |
</div> |
| 111 |
<?php |
| 112 |
} |
| 113 |
} |
| 114 |
|