Please enter Aspose SID and Key on plugin settings page.
';
return;
}
if(isset($_POST['ape-export_submit_button'])) {
$post_params = $_POST;
$query_args = array();
$query_args['posts_per_page'] = -1;
$query_args['date_query'] = array();
// Query on Post types
if(isset($post_params['ape-allposts-export_post_types']) && !empty($post_params['ape-allposts-export_post_types'])) {
$query_args['post_type'] = $post_params['ape-allposts-export_post_types'];
}
// Query on Author
if(isset($post_params['ape-allposts-export_authors']) && !empty($post_params['ape-allposts-export_authors'])) {
$query_args['author__in'] = $post_params['ape-allposts-export_authors'];
}
// Query on Category
if(isset($post_params['ape-allposts-export_categories']) && !empty($post_params['ape-allposts-export_categories'])) {
$query_args['category__in'] = $post_params['ape-allposts-export_categories'];
}
// Query on Date Range
if(isset($post_params['ape-allposts-export_from']) && !empty($post_params['ape-allposts-export_from'])) {
$query_args['date_query'][] = array(
'column' => 'post_date_gmt',
'after' => strtotime($post_params['ape-allposts-export_from']),
);
}
// Query on Date Range
if(isset($post_params['ape-allposts-export_to']) && !empty($post_params['ape-allposts-export_to'])) {
$query_args['date_query'][] = array(
'column' => 'post_date_gmt',
'before' => strtotime($post_params['ape-allposts-export_to']),
);
}
$the_query = new WP_Query( $query_args );
$filtered_post_ids = array();
if ( $the_query->have_posts() ) {
while ( $the_query->have_posts() ) : $the_query->the_post();
$filtered_post_ids[] = get_the_ID();
endwhile;
wp_reset_query();
if(($key = array_search($post_params['intro_page_id'], $filtered_post_ids)) !== false) {
unset($filtered_post_ids[$key]);
}
array_unshift($filtered_post_ids,$post_params['intro_page_id']);
$posts_contents = aspose_posts_exporter_array_builder($filtered_post_ids,$post_params);
if ( is_array($posts_contents) && count($posts_contents) > 0 ) {
$file_name = aspose_posts_exporter_array_to_html($posts_contents);
//$message1 = count($posts_contents) . ' found, matching your criteria.';
//echo "";
include_once('aspose_posts_exporter_doc_converter.php');
} else {
wp_die( __('Error exporting post.') );
}
} else {
$message2 = 'Sorry, no posts matched your criteria.';
echo "";
}
//die('done');
}
require_once('ape-admin-main.php');
}
add_action( 'admin_menu', 'register_aspose_posts_exporter_menu_page' );
function aspose_posts_exporter_enqueue_scripts() {
wp_register_script('APEScript', plugins_url('js/script.js', __FILE__ ), array('jquery'));
wp_register_style('APEStyle', plugins_url('css/style.css', __FILE__), array(), '');
$js_params = array();
wp_localize_script('APEScript', 'APE_Params', $js_params);
wp_enqueue_script('APEScript');
wp_enqueue_style('APEStyle');
// jQuery UI Scripts / Styles
wp_enqueue_script('jquery-ui-datepicker');
wp_enqueue_script('jquery-ui-tabs');
wp_enqueue_style( 'jquery-ui-tabs');
wp_enqueue_style('APE-jquery-ui-style', 'http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.2/themes/smoothness/jquery-ui.css');
define('APE_PLUGIN_BASE_PATH', plugin_dir_path(__FILE__));
}
add_action('admin_init', 'aspose_posts_exporter_enqueue_scripts');
function includeSourceLinktoPost($content) {
return $content . "" . " Source
";
}
function includeDatetoPostTitle($title){
return $title . '' . get_the_time('F j, Y',get_the_ID()) .'
';
}
function aspose_posts_exporter_array_builder($post_ids,$post_params) {
if($post_params['show_source_link'] == 'yes'){
add_filter('the_content',includeSourceLinktoPost);
}
if($post_params['show_post_date'] == 'yes'){
add_filter('the_title',includeDatetoPostTitle);
}
$count = 0;
foreach($post_ids as $post_id) {
if($count == 1){
$post_contents['Copyright'] = $post_params['copy_right_details'];
}
$post_data = get_post($post_id);
$post_title = apply_filters('the_title',$post_data->post_title);
$post_content = apply_filters('the_content',$post_data->post_content) ;
// $post_content = $post_data->post_content;
$post_contents[$post_title] = $post_content;
$count ++;
}
$post_contents['Colophon'] = $post_params['colophon_details'];
if(is_array($post_contents)) {
return $post_contents;
} else {
return false;
}
}
function aspose_posts_exporter_array_to_html($post_contents){
global $ape_html_filename;
$upload_dir = wp_upload_dir();
$upload_path = $upload_dir['path'] . '/';
$ape_html_filename = 'output_'.time().'.htm';
$output_string = <<
EOD;
foreach($post_contents as $key => $value) {
$output_string .= << {$key}
{$value}
EOD;
}
$output_string .= <<
EOD;
@unlink($upload_path . $ape_html_filename);
file_put_contents($upload_path . $ape_html_filename, $output_string);
return $upload_path . $ape_html_filename;
}
/**
* Pluing settings page
* @param no-param
* @return no-return
*/
function AsposePostsExporterAdminContent() {
// Creating the admin configuration interface
?>