Skip to content

Commit

Permalink
Updated code styling to follow wordpress codestyle
Browse files Browse the repository at this point in the history
  • Loading branch information
fkrauthan committed Oct 4, 2017
1 parent b70e192 commit df44e76
Show file tree
Hide file tree
Showing 7 changed files with 898 additions and 799 deletions.
64 changes: 32 additions & 32 deletions cronCreatePDFs.php
@@ -1,62 +1,62 @@
<?php
/*
* This file is part of wp-mpdf.
* This file is part of wp-mpdf.
* wp-mpdf is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any later version.
*
* Software Foundation, either version 3 of the License, or (at your option) any later version.
*
* wp-mpdf is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with wp-mpdf. If not, see <http://www.gnu.org/licenses/>.
*/


//Call this script from a cron job to create/update the pdf cache
require_once(dirname(__FILE__).'/../../../wp-config.php');
require_once(dirname(__FILE__).'/wp-mpdf.php');
require_once( dirname( __FILE__ ) . '/../../../wp-config.php' );
require_once( dirname( __FILE__ ) . '/wp-mpdf.php' );


//Disable the Timeout
set_time_limit(0);
set_time_limit( 0 );


//Check if Caching is enabled or not
if(get_option('mpdf_caching')!=true) {
if ( get_option( 'mpdf_caching' ) != true ) {
echo "No caching enabled\n";
exit(-1);
exit( - 1 );
}


//Do login if is whished
if(get_option('mpdf_cron_user') != '') {
$userId = get_option('mpdf_cron_user');
if(get_option('mpdf_cron_user') == 'auto') {
$aUsersID = $wpdb->get_col($wpdb->prepare('SELECT ID FROM '.$wpdb->users.' LIMIT 1'));
foreach($aUsersID as $iUserID) {
$userId = $iUserID;
}
}

wp_set_current_user($userId);
if ( get_option( 'mpdf_cron_user' ) != '' ) {
$userId = get_option( 'mpdf_cron_user' );
if ( get_option( 'mpdf_cron_user' ) == 'auto' ) {
$aUsersID = $wpdb->get_col( $wpdb->prepare( 'SELECT ID FROM ' . $wpdb->users . ' LIMIT 1' ) );
foreach ( $aUsersID as $iUserID ) {
$userId = $iUserID;
}
}

wp_set_current_user( $userId );
}


//Cache the posts
$_GET['output'] = 'pdf';
echo "Start cache creating\n";

$posts = get_posts('numberposts=-1&order=ASC&orderby=title');
foreach($posts as $post) {
if($post->post_title == '') {
echo "Skip post creating: No Title (".$post->ID.")\n";
continue;
}
echo "Create cache for post (".$post->ID.")\n";

query_posts('p='.$post->ID);
mpdf_exec('false');
$posts = get_posts( 'numberposts=-1&order=ASC&orderby=title' );
foreach ( $posts as $post ) {
if ( $post->post_title == '' ) {
echo "Skip post creating: No Title (" . $post->ID . ")\n";
continue;
}

echo "Create cache for post (" . $post->ID . ")\n";


query_posts( 'p=' . $post->ID );
mpdf_exec( 'false' );
}

echo "Caching finished\n";
Expand Down
33 changes: 17 additions & 16 deletions geshi.inc.php
@@ -1,20 +1,21 @@
<?php
/*
* This file is part of wp-mpdf.
* wp-mpdf is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free * Software Foundation, either version 3 of the License, or (at your option) any later version.
*
* wp-mpdf is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with wp-mpdf. If not, see <http://www.gnu.org/licenses/>.
*/
/*
* This file is part of wp-mpdf.
* wp-mpdf is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free * Software Foundation, either version 3 of the License, or (at your option) any later version.
*
* wp-mpdf is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with wp-mpdf. If not, see <http://www.gnu.org/licenses/>.
*/


require_once(dirname(__FILE__).'/wp_syntax_functions.inc.php');

function ParseGeshi($content) {
$content = wp_syntax_before_filter($content);
$content = wp_syntax_after_filter_mpdf($content);

return $content;
}
require_once( dirname( __FILE__ ) . '/wp_syntax_functions.inc.php' );

function ParseGeshi( $content ) {
$content = wp_syntax_before_filter( $content );
$content = wp_syntax_after_filter_mpdf( $content );

return $content;
}

?>
48 changes: 25 additions & 23 deletions get_mark.inc.php
@@ -1,30 +1,32 @@
<?php
/*
* This file is part of wp-mpdf.
* wp-mpdf is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free * Software Foundation, either version 3 of the License, or (at your option) any later version.
*
* wp-mpdf is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with wp-mpdf. If not, see <http://www.gnu.org/licenses/>.
*/
/*
* This file is part of wp-mpdf.
* wp-mpdf is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free * Software Foundation, either version 3 of the License, or (at your option) any later version.
*
* wp-mpdf is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with wp-mpdf. If not, see <http://www.gnu.org/licenses/>.
*/


function get_mark($string,$mark) {
$ausgabe = array();
$template = explode("*",$mark);
$mark = $template[0];
$end = $template[1];
$string = strstr($string,$mark);
function get_mark( $string, $mark ) {
$ausgabe = array();
$template = explode( "*", $mark );
$mark = $template[0];
$end = $template[1];
$string = strstr( $string, $mark );

$temp = explode($mark,$string);
$a = 1;
foreach ($temp as $tempx) {
$tempx = explode($end,$tempx);
$tempx = $tempx[0];
if ($tempx) {
array_push ($ausgabe,$tempx);
}
$temp = explode( $mark, $string );
$a = 1;
foreach ( $temp as $tempx ) {
$tempx = explode( $end, $tempx );
$tempx = $tempx[0];
if ( $tempx ) {
array_push( $ausgabe, $tempx );
}
return $ausgabe;
}

return $ausgabe;
}

?>

0 comments on commit df44e76

Please sign in to comment.