-
Notifications
You must be signed in to change notification settings - Fork 0
/
more-products.php
81 lines (70 loc) · 2.8 KB
/
more-products.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
<?php
if( !class_exists('CC_Product_Page') ) :
class CC_Product_Page {
public function __construct() {
add_action( 'admin_menu' , array( $this, 'add_product_page' ) );
add_action( 'admin_print_scripts' , array( $this, 'print_product_page_scripts' ) );
}
public function add_product_page() {
add_submenu_page ( 'edit.php?post_type=sm_shortcode', 'Cybercraft Products', 'Cybercraft Products', 'manage_options', __FILE__, array( $this, 'build_plugin_page' ) );
}
function build_plugin_page() {
if ( ! function_exists( 'plugins_api' ) ) {
$admin_path = trailingslashit( str_replace( site_url() . '/', ABSPATH, get_admin_url() ) );
require_once( $admin_path . 'includes/plugin-install.php' );
}
$call_api = plugins_api( 'query_plugins', array( 'author' => array( 'cybercraftit', 'mithublue', 'zenithx' ), 'fields' => array( 'banners' => true ) ) );
if ( is_wp_error( $call_api ) ) {
echo '<pre>' . print_r( $call_api->get_error_message(), true ) . '</pre>';
} else {
//echo base64_encode(json_encode( $call_api ));
echo '<div class="cc-product-wrapper">';
foreach( $call_api->plugins as $number => $plugin ) {
?>
<div class="cc-product-holder">
<img src="<?php echo isset( $plugin->banners['low'] ) ? $plugin->banners['low'] : '' ?>" width="100%" alt="Banner"/>
<h3><a href="https://wordpress.org/plugins/<?php echo $plugin->slug; ?>" target="_blank"><?php echo $plugin->name ?></a></h3>
<p><?php echo $plugin->short_description; ?></p>
<a class="btn btn-visit" href="https://wordpress.org/plugins/<?php echo $plugin->slug; ?>" target="_blank"">Visit plugin page</a>
</div>
<?php
}
echo '</div>';
}
}
/**
* scripts and styles of product page
*/
function print_product_page_scripts( $hook ) {
?>
<style>
.cc-product-holder a {
text-decoration: none;
}
.cc-product-wrapper{
overflow: hidden;
}
.cc-product-holder{
border: 1px solid #cccccc;
border-radius: 3px;
width: 300px;
height: 300px;
float: left;
padding: 10px 10px;
margin: 3px;
}
.cc-product-holder .btn-visit{
padding: 7px 10px;
background: #05b93a;
border-radius: 3px;
color: #ffffff;
}
</style>
<?php
}
public static function init() {
new CC_Product_Page();
}
}
CC_Product_Page::init();
endif;