"AWeber",
"forms.aweber.com" => "Aweber",
"list-manage.com" => "MailChimp",
"list-manage1.com" => "MailChimp",
"app.getresponse.com" => "GetResponse",
"bz9.com" => "BZ9"
);
/**
* Initial setup
*/
function __construct() {
if( is_admin() )
{
add_action( 'wp_ajax_armagic_shortpop', array( $this, 'armagic_shortpop_ajax' ) );
add_action( 'init', array(&$this, 'armagic_custom_init' ), 9 );
add_action( 'add_meta_boxes', array( $this, 'add_meta_box' ) );
add_action( 'save_post', array( $this, 'save' ) );
add_filter( 'manage_edit-ar_magic_columns', array( $this, 'armagic_columns' ) ) ;
add_action( 'manage_posts_custom_column', array( $this, 'armagic_populate_columns' ) );
add_action( 'init', array(&$this, 'add_editor_button' ) );
add_action( 'admin_menu', array( $this, 'armagic_register_submenu_page' ) );
add_filter( 'enter_title_here', array( $this, 'armagic_enter_title_here' ) );
if ( ( isset( $_GET['post_type'] ) && $_GET['post_type'] == 'ar_magic' ) || ( isset( $post_type ) && $post_type == 'ar_magic' ) || ( isset( $_GET['post'] ) && get_post_type( $_GET['post'] ) == 'ar_magic' ) )
{
add_action('admin_enqueue_scripts', array( $this, 'armagic_admin_scripts' ) );
}
add_action( 'admin_head', array( $this, 'armagic_plugin_header' ) );
add_filter( 'post_row_actions', array( $this, 'armagic_remove_quick_edit' ) );
add_filter( 'post_updated_messages', array( $this, 'armagic_updated_messages' ) );
} else {
add_shortcode( 'ar_magic', array(&$this, 'js_shortcode' ) );
}
}
/**
* Include popup window content
*/
public function armagic_shortpop_ajax(){
if ( !current_user_can( 'edit_pages' ) && !current_user_can( 'edit_posts' ) )
die(__("You are not allowed to be here"));
include_once('form.php');
die();
}
function startsWith($haystack, $needle)
{
return $needle === "" || strpos($haystack, $needle) === 0;
}
/**
* Shortcode handler
*/
function js_shortcode( $atts = array(), $content = null ){
$out = '';
$sc_atts = array();
extract( shortcode_atts( array(
'saved' => ''
), $atts ) );
if ($saved != '')
{
$saved_ar = get_post_meta( $saved, 'armagic_respcode', true );
return $saved_ar;
}
if( $content )
{
if( is_array( $content ) )
{
foreach ( $content as $key => $content_new )
{
$out .= $this->process_sc( $content_new );
}
} else {
$out .= $this->process_sc($content, $sc_atts );
}
}
return $out;
}
/**
* Process shortcode
*/
private function process_sc( $content, $sc_atts=null ){
$content = str_replace('~','"',$content);
$content = html_entity_decode($content);
if($this->armagic_validate_ar( $content ))
{
return $content;
}
return;
}
/**
* Print footer scripts
*/
function call_js(){
wp_print_scripts( $this->handles );
}
/**
* Register editor button
*/
function register_button( $buttons ) {
array_push( $buttons, "|", "ar_magic" );
return $buttons;
}
/**
* Add editor plugin
*/
function add_plugin( $plugin_array ) {
$plugin_array['ar_magic'] = WP_PLUGIN_URL.'/ar-magic/js/ar_magic.js';
return $plugin_array;
}
/**
* Add editor button
*/
function add_editor_button() {
if ( ! current_user_can( 'edit_posts' ) && ! current_user_can( 'edit_pages' ) ) {
return;
}
if ( get_user_option( 'rich_editing' ) == 'true' ) {
add_filter( 'mce_external_plugins', array( &$this, 'add_plugin' ) );
add_filter( 'mce_buttons', array( &$this, 'register_button' ) );
}
}
/**
* Custom post setup
*/
function armagic_custom_init() {
$labels = array(
'name' => 'Your Saved Auto Responders',
'singular_name' => 'Auto Responder',
'add_new' => 'Add Responder',
'add_new_item' => 'Add Responder',
'edit_item' => 'Edit Auto Responder',
'new_item' => 'New Auto Responder',
'all_items' => 'Saved Responders',
'view_item' => 'View Auto Responder',
'search_items' => 'Search Auto Responders',
'not_found' => 'No Auto Responders found',
'not_found_in_trash' => 'No Auto Responders found in Trash',
'parent_item_colon' => '',
'menu_name' => 'AR Magic'
);
$args = array(
'labels' => $labels,
'public' => false,
'publicly_queryable' => false,
'show_ui' => true,
'menu_position' => 5,
'query_var' => false,
'rewrite' => false,
'capability_type' => 'post',
'has_archive' => false,
'hierarchical' => false,
'menu_position' => null,
'menu_icon' => plugins_url( 'ar-magic/images/arMagic_logo16.png' ),
'supports' => array( 'title')
);
register_post_type( 'ar_magic', $args );
}
/**
* Set custom messages
*/
function armagic_updated_messages( $messages ) {
global $post, $post_ID;
$messages['ar_magic'] = array(
0 => '',
1 => __('Your auto responder has been updated.' ),
2 => __('Custom field updated.'),
3 => __('Custom field deleted.'),
4 => __('Your auto responder has been updated.'),
5 => isset($_GET['revision']) ? sprintf( __('auto responder restored to revision from %s'), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false,
6 => __('Your auto responder has been saved.'),
7 => __('Your auto responder has been saved.'),
8 => sprintf( __('Auto responder submitted. Preview Tool'), esc_url( add_query_arg( 'preview', 'true', get_permalink($post_ID) ) ) ),
9 => sprintf( __('Auto responder scheduled for: %1$s. Preview Tool'), date_i18n( __( 'M j, Y @ G:i' ), strtotime( $post->post_date ) ), esc_url( get_permalink($post_ID) ) ),
10 => sprintf( __('Auto responder draft updated. Preview Tool'), esc_url( add_query_arg( 'preview', 'true', get_permalink($post_ID) ) ) ),
);
return $messages;
}
/**
* Adds the meta box container
*/
public function add_meta_box() {
add_meta_box(
'armagic_descr',
'Auto Responder Details',
array( &$this, 'render_meta_box_content' ),
'ar_magic',
'normal',
'high'
);
}
/**
* Render Meta Box content
*/
public function render_meta_box_content( $post ) {
// Use nonce for verification
wp_nonce_field( plugin_basename( __FILE__ ), 'armagic_noncename' );
$value = get_post_meta( $post->ID, 'armagic_descr', true );
$value2 = get_post_meta( $post->ID, 'armagic_respcode', true );
/*echo ' ';
echo '
';
echo '
'; echo '
';*/ echo '| '; echo ' | '; echo ' |
|---|---|
| '; echo ' | '; echo ' |