connect = new Connect_DB(); } // ****************************** CACHE ********************************// /** * * SAVE CACHE FILE * * @param string $html_conteudo html content to cache * * @return */ // ***********************************************************************// public function cache_file( $html_conteudo, $path_file ) { file_put_contents( $path_file, ''.$html_conteudo ); } // ********************* DOWNLOAD IMAGES LOCALY ************************// /** * * DOWNLOAD IMAGES TO LOCAL SERVER * * @param string $image_url | string $file_name * * @return string "Image path url" */ // ***********************************************************************// public function download_and_get_path_image($image_url, $file_name) { $image_temp_file = WP_CONTENT_DIR.'/cache/'; $get_image_file = WP_CONTENT_URL.'/cache/'; $image = wp_remote_retrieve_body( wp_remote_get($image_url) ); file_put_contents( $image_temp_file.$file_name, $image ); return $get_image_file.$file_name; } // **************************** BUILD STRUCTURE **************************// /** * * RETURN THE PLUGIN HTML STRUCTURE * * @param boolean $premium_user false if check if user is premium * * @return string */ // ***********************************************************************// public function build_structure( $premium_user = false, $theme, $path_file ) { // if permission denied if ( !is_writable( WP_CONTENT_DIR.'/cache/' ) ) { /********************* > ERROR - if directory doesn't exist or isn't writable. **********************/ add_action( 'admin_notices', array( $this, 'gchelp_notice_error_write' ) ); } else { require_once plugin_dir_path(__DIR__) . 'includes/gchelp-restapi.php'; $api = new GCHelp_API(); // function get_posts( $postperpage = 10, $orderby = 'name', $order = 'asc', $category = null ) $posts_insights = $api->get_posts( 15, 'date', 'desc', 1 ); $posts_cursos = $api->get_posts( 15, 'date', 'desc', 2 ); if ( ! empty( $posts_cursos ) && ! is_wp_error( $posts_cursos ) ) { if ( ! empty( $posts_insights ) && ! is_wp_error( $posts_insights ) ) { if ( $theme == 'darktech' ) { $tech = 'is-tech'; $tech_img = 'tech-'; $active_t = '-active'; } else { $tech = ''; $tech_img = ''; $active_t = ''; } /******** PREPARA O CONTEÚDO DE INSIGHTS *********/ $conteudo_dinamico_insights = ''; $i = 0; foreach ($posts_insights as $value) { $id_image = ''; $image_url = ''; $id_image = $value->featured_media; if ( $id_image != 0 ) { $object_image = $api->get_post_media( $id_image ); if ( isset( $object_image->guid->rendered ) ) { $image_url = $object_image->guid->rendered; } } if ( $image_url == '' ) $image_url = plugins_url().'/gc-help/admin/images/gcampaner.jpg'; $conteudo = $value->content->rendered; $titulo = $value->title->rendered; //if ( $i != 0 ) { if ( true ) { //download_and_get_path_image($image_url, $file_name) $image_path = self::download_and_get_path_image($image_url, sanitize_title($titulo).'.jpg' ); $conteudo_dinamico_insights .= '

'.$titulo.'

'; } else { $conteudo_dinamico_insights .= '

'.$titulo.'

'.substr( strip_tags($conteudo), 0, 150).'...

'; } $i++; } /******** PREPARA O CONTEÚDO DE CURSOS *********/ $conteudo_dinamico_cursos = ''; $i = 0; foreach ($posts_cursos as $value) { $id_image = ''; $image_url = ''; $id_image = $value->featured_media; if ( $id_image != 0 ) { $object_image = $api->get_post_media( $id_image ); $image_url = $object_image->media_details->sizes->medium->source_url; } if ( $image_url == '' ) $image_url = plugins_url().'/gc-help/admin/images/gcampaner.jpg'; $conteudo = $value->content->rendered; $titulo = $value->title->rendered; //if ( $i != 0 ) { if ( true ) { //download_and_get_path_image($image_url, $file_name) $image_path = self::download_and_get_path_image($image_url, sanitize_title($titulo).'.jpg' ); $conteudo_dinamico_cursos .= '

'.$value->title->rendered.'

'; } else { $conteudo_dinamico_cursos .= '

'.$value->title->rendered.'

'.substr( strip_tags($value->content->rendered), 0, 150).'...

'; } $i++; } /************************************************** BLOCO QUE VERIFICA SE HÁ POST NOVO **************************************************/ //$date_last_check = $this->user['last_push_check']; //$date_last_post = $this->connect->check_ultimo_post(); //$date_last_post_DATE = new DateTime( $date_last_post ); //$date_last_check_DATE = new DateTime( $date_last_check ); //$interval = $date_last_check_DATE->diff($date_last_post_DATE); //$push_notifications = $api->get_push(); /* CRIA O BOX DE PUSH NOTIFICATIONS */ //$push_messages = ''; //if ( $interval->days > 0 && $interval->invert == 0 ) { $push_notification_html = '
'; //} else { // $push_notification_html = ' // '.$push_messages.' //
//
// '; //} /************************************************** / BLOCO QUE VERIFICA SE HÁ POST NOVO **************************************************/ #__Estrutura $html_conteudo = ''; $html_conteudo .= '
'.$push_notification_html.'
'; $minified_html_conteudo = preg_replace(array('//Uis',"/[[:blank:]]+/"),array('',' '),str_replace(array("\n","\r","\t"),'',$html_conteudo)); #CACHE self::cache_file( $minified_html_conteudo, $path_file ); } // IF NOT !posts_insights } // IF NOT !posts_cursos } // IF FILE IS WRITABLE } // ***************************** INIT STRUCTURE ***************************// /** * * RETURN HTML STRUCTURE TO PREMIUM OR REGULAR USERS * * @return string */ // ***********************************************************************// public function init_structure() { $path_file_dark = WP_CONTENT_DIR.'/cache/gc-help-dark.html'; $file_time_dark = @filemtime( $path_file_dark ); $path_file_light = WP_CONTENT_DIR.'/cache/gc-help-light.html'; $file_time_light = @filemtime( $path_file_light ); $current_time = time(); $expire_time = self::CACHE_TIME * 60; if ( !file_exists( $path_file_dark ) || $file_time_dark < ( $current_time - $expire_time ) ) { self::build_structure( false, 'darktech', $path_file_dark ); } if ( !file_exists( $path_file_light ) || $file_time_light < ( $current_time - $expire_time ) ) { self::build_structure( false, 'light', $path_file_light ); } } public function print_html() { $path_file_dark = WP_CONTENT_DIR.'/cache/gc-help-dark.html'; $path_file_light = WP_CONTENT_DIR.'/cache/gc-help-light.html'; if ( file_exists($path_file_dark) && file_exists($path_file_light) ) { if ( get_option('gchelpset-select') == 'darktech' ) { echo file_get_contents($path_file_dark); } else { echo file_get_contents($path_file_light); } } // user name $current_user = wp_get_current_user(); echo ''; } // ***************************** NOTICES ADMIN ***************************// /** * * SHOW NOTICE IN WORDPRESS ADMIN * * @return string */ // ***********************************************************************// public function gchelp_notice_error_write() { ?>

Erro de permissão de escrita em /wp-content/cache', 'sample-text-domain' ); ?>

A função allow_url_fopen de seu servidor está desativada. Contate o administrador ou ative-a para o funcionamento do plugin', 'sample-text-domain' ); ?>