get_gutenberg_module_enabled() || atkp_options::$loader->get_shortcodegenerator_module_enabled() ) {
add_action( 'media_buttons', array( &$this, 'shortcode_buttons' ) );
}
add_action('admin_head', array(&$this, 'atkp_add_my_tc_button'));
//add_action( 'media_buttons', array(&$this, 'shortcode_popup' ) );
add_action( 'admin_footer', array(&$this, 'shortcode_popup' ) );
//add_action( 'wp_footer', array(&$this, 'shortcode_popup' ) );
}
function atkp_add_my_tc_button() {
global $typenow;
// check user permissions
//if ( !current_user_can('edit_posts') && !current_user_can('edit_pages') ) {
//return;
//}
// verify the post type
$page = ATKPTools::get_get_parameter( 'page', 'string');
$allowed_pages = array();
array_push($allowed_pages, 'ATKP_affiliate_toolkit-plugin');
$sel_post_types = get_option(ATKP_PLUGIN_PREFIX.'_custom_posttypes', null);
if($sel_post_types == null || !is_array($sel_post_types))
$sel_post_types = array();
array_push($sel_post_types, 'post');
array_push($sel_post_types, 'page');
array_push($sel_post_types, ATKP_PRODUCT_POSTTYPE);
if( ! in_array( $typenow, $sel_post_types) && !in_array( $page, $allowed_pages) )
return;
// check if WYSIWYG is enabled
//if ( get_user_option('rich_editing') == 'true') {
add_filter('mce_external_plugins', array(&$this, 'addbuttons'));
add_filter('mce_buttons', array(&$this, 'registerbuttons'));
//}
}
function addbuttons($plugin_array) {
$plugin_array['atkp_button_picker'] = plugins_url( '/js/editor-button.js', ATKP_PLUGIN_FILE ); // CHANGE THE BUTTON SCRIPT HERE
return $plugin_array;
}
function registerbuttons($buttons) {
array_push($buttons, 'separator', 'atkp_button_picker');
return $buttons;
}
function shortcode_popup() {
if( atkp_options::$loader->get_gutenberg_module_enabled() ) {
$args = array();
$args['echo'] = true;
$this->shortcode_buttons($args);
}
//TODO: implement cache
?>
template_detail_box_content('');
?>
Affiliate-Toolkit Shortcode';
$post = get_post();
if($post)
$typenow = $post->post_type;
else
$typenow = '';
$sel_post_types = get_option(ATKP_PLUGIN_PREFIX.'_custom_posttypes', null);
$page = ATKPTools::get_get_parameter( 'page', 'string');
$allowed_pages = array();
array_push($allowed_pages, 'ATKP_affiliate_toolkit-plugin');
if($sel_post_types == null || !is_array($sel_post_types))
$sel_post_types = array();
array_push($sel_post_types, 'post');
array_push($sel_post_types, 'page');
array_push($sel_post_types, ATKP_PRODUCT_POSTTYPE);
if( ! in_array( $typenow, $sel_post_types) && ! in_array( $page, $allowed_pages))
return;
$target = is_string( $args ) ? $args : 'content';
// Prepare args
$args = wp_parse_args( $args, array(
'target' => $target,
'text' => __( 'affiliate-toolkit Shortcodes', ATKP_PLUGIN_PREFIX ),
'class' => 'button',
'icon' => plugins_url( 'images/affiliate_toolkit_menu.png', ATKP_PLUGIN_FILE ),
'echo' => true,
'shortcode' => false
) );
// Prepare icon
if ( $args['icon'] ) $args['icon'] = '
';
$additional_shortcode_button= get_option(ATKP_PLUGIN_PREFIX.'_additional_shortcode_button', 0) ? '' : 'display:none;';
// Print button
$button = '' . $args['icon'] . $args['text'] . '';
wp_register_style( 'magnific-popup', plugins_url( 'css/magnific-popup.css', ATKP_PLUGIN_FILE ), false, '0.9.9', 'all' );
wp_register_script( 'magnific-popup', plugins_url( 'js/magnific-popup.js', ATKP_PLUGIN_FILE ), array( 'jquery' ), '0.9.9', true );
wp_localize_script( 'magnific-popup', 'atkp_magnific_popup', array(
'close' => __( 'Close (Esc)', ATKP_PLUGIN_PREFIX ),
'loading' => __( 'Loading...', ATKP_PLUGIN_PREFIX ),
'prev' => __( 'Previous (Left arrow key)', ATKP_PLUGIN_PREFIX ),
'next' => __( 'Next (Right arrow key)', ATKP_PLUGIN_PREFIX ),
'counter' => sprintf( __( '%s of %s', ATKP_PLUGIN_PREFIX ), '%curr%', '%total%' ),
'error' => sprintf( __( 'Failed to load this link. %sOpen link%s.', ATKP_PLUGIN_PREFIX ), '', '' )
) );
wp_enqueue_style( 'magnific-popup' );
wp_enqueue_script( 'magnific-popup' );
if ( $args['echo'] )
echo $button;
else
return $button;
}
function shortcode_boxes() {
$types = array( 'post', 'page' );
foreach( $types as $type ) {
add_meta_box(
ATKP_PLUGIN_PREFIX.'_product_box',
__( 'Affiliate Toolkit Product', ATKP_PLUGIN_PREFIX),
array(&$this, 'product_detail_box_content'),
$type,
'normal',
'default'
);
}
}
function product_detail_box_content( $post )
{
wp_nonce_field( plugin_basename( __FILE__ ), 'product_detail_box_content_nonce' );
?>
array( 'post', 'page' ), // YOUR POST TYPE
'post_status' => array('publish', 'draft'),
'meta_query' => array(
array(
'key' => ATKP_PLUGIN_PREFIX.'_product',
'value' => $prdid,
'compare' => '=',
'type' => 'CHAR',
),
),
);
// The Query
$query = new WP_Query( $args );
if ( $query->have_posts() ) {
while ( $query->have_posts() ) {
$query->the_post();
array_push($postids, $query->post->ID);
}
}
wp_reset_postdata();
ATKPTools::set_post_setting( $prdid, ATKP_PRODUCT_POSTTYPE.'_postid', $postids);
}
}
function template_detail_box_content( $post ) {
?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|