),
);
if ( $imagick ) {
$gmagick_imagick_position = array_search( 'GMagick or IMagick', array_keys( $server_configs ) ) + 1;
$image_magick_config = array(
'ImageMagick' => array(
'required' => __( 'Required for IMagick', 'woocommerce-pdf-invoices-packing-slips' ),
'value' => ( $imagick && class_exists( '\\Imagick' ) ) ? esc_attr( \Imagick::getVersion()['versionString'] ) : null,
'result' => $imagick,
'fallback' => __( 'ImageMagick library, integrated via the IMagick PHP extension for advanced image processing capabilities', 'woocommerce-pdf-invoices-packing-slips' ),
),
);
$server_configs = array_slice( $server_configs, 0, $gmagick_imagick_position, true ) + $image_magick_config + array_slice( $server_configs, $gmagick_imagick_position, null, true );
}
if ( $xc || $apc || $zop || $op ) {
$server_configs['opcache']['result'] = true;
if ( $xc ) {
$server_configs['opcache']['value'] = 'XCache ' . phpversion( 'xcache' );
} elseif ( $apc ) {
$server_configs['opcache']['value'] = 'APC ' . phpversion( 'apc' );
} elseif ( $zop ) {
$server_configs['opcache']['value'] = 'Zend OPCache ' . phpversion( 'Zend OPcache' );
} else {
$server_configs['opcache']['value'] = 'PHP OPCache ' . phpversion( 'opcache' );
}
}
return (array) apply_filters(
'wpo_wcpdf_server_configs',
$server_configs
);
}
/**
* Set a notice to be displayed if the server requirements are not met.
*
* @return void
*/
public function handle_server_requirement_notice(): void {
// Return if the notice has been dismissed.
if ( get_option( 'wpo_wcpdf_dismiss_requirements_notice', false ) ) {
return;
}
// Handle dismissal action.
Notices::handle_notice_action(
'wpo_dismiss_requirements_notice',
'dismiss_requirements_notice',
function (): void {
update_option( 'wpo_wcpdf_dismiss_requirements_notice', true );
},
admin_url( 'admin.php?page=wpo_wcpdf_options_page' )
);
// Check if the server requirements are met.
$show_requirement_notice = false;
$server_configs = $this->get_server_config();
foreach ( $server_configs as $config_name => $config ) {
if ( in_array( $config_name, array( 'opcache', 'GMagick or IMagick', 'WP Memory Limit' ), true ) ) {
continue;
}
if ( ! $config['result'] ) {
$show_requirement_notice = true;
break;
}
}
// Return if the server requirements are met.
if ( ! $show_requirement_notice ) {
return;
}
// Display the notice.
Notices::maybe_add_admin_notice( array( Notices::class, 'display_server_requirement_notice' ) );
}
/**
* Get the premium plugins data.
*
* @return array
*/
public function get_premium_plugins(): array {
$premium_plugins = apply_filters(
'wpo_wcpdf_premium_plugins',
array(
'woocommerce-pdf-ips-pro/woocommerce-pdf-ips-pro.php' => 'wpo_wcpdf_pro_license',
'woocommerce-pdf-ips-templates/woocommerce-pdf-ips-templates.php' => 'wpo_wcpdf_templates_license',
)
);
// Get base data (name, version, is_active)
$plugin_files = array_keys( $premium_plugins );
$plugins = wpo_ips_get_plugins_data( $plugin_files );
// Add license keys
$licenses = get_option( 'wpocore_settings', array() );
foreach ( $plugins as $plugin_file => &$data ) {
$license_slug = $premium_plugins[ $plugin_file ] ?? '';
$data['license_key'] = $license_slug && isset( $licenses[ $license_slug ] ) ? $licenses[ $license_slug ] : '';
}
unset( $data ); // break the reference
return (array) apply_filters(
'wpo_wcpdf_premium_plugins_data',
$plugins
);
}
/**
* Get the write permissions for the plugin directories.
*
* @return array
*/
public function get_directory_permissions(): array {
$status = array(
'ok' => __( 'Writable', 'woocommerce-pdf-invoices-packing-slips' ),
'failed' => __( 'Not writable', 'woocommerce-pdf-invoices-packing-slips' ),
);
$file_system_instance = WPO_WCPDF()->get_instance( 'file_system' );
$main_instance = WPO_WCPDF()->get_instance( 'main' );
$permissions = array(
'WCPDF_TEMP_DIR' => array(
'description' => __( 'Central temporary plugin folder', 'woocommerce-pdf-invoices-packing-slips' ),
'value' => $main_instance->get_tmp_path(),
'status' => $file_system_instance->is_writable( $main_instance->get_tmp_path() ) ? 'ok' : 'failed',
'status_message' => $file_system_instance->is_writable( $main_instance->get_tmp_path() ) ? $status['ok'] : $status['failed'],
),
'WCPDF_ATTACHMENT_DIR' => array(
'description' => __( 'Temporary attachments folder', 'woocommerce-pdf-invoices-packing-slips' ),
'value' => trailingslashit( $main_instance->get_tmp_path( 'attachments' ) ),
'status' => $file_system_instance->is_writable( $main_instance->get_tmp_path( 'attachments' ) ) ? 'ok' : 'failed',
'status_message' => $file_system_instance->is_writable( $main_instance->get_tmp_path( 'attachments' ) ) ? $status['ok'] : $status['failed'],
),
'DOMPDF_TEMP_DIR' => array(
'description' => __( 'Temporary DOMPDF folder', 'woocommerce-pdf-invoices-packing-slips' ),
'value' => trailingslashit( $main_instance->get_tmp_path( 'dompdf' ) ),
'status' => $file_system_instance->is_writable( $main_instance->get_tmp_path( 'dompdf' ) ) ? 'ok' : 'failed',
'status_message' => $file_system_instance->is_writable( $main_instance->get_tmp_path( 'dompdf' ) ) ? $status['ok'] : $status['failed'],
),
'DOMPDF_FONT_DIR' => array(
'description' => __( 'DOMPDF fonts folder (needs to be writable for custom/remote fonts)', 'woocommerce-pdf-invoices-packing-slips' ),
'value' => trailingslashit( $main_instance->get_tmp_path( 'fonts' ) ),
'status' => $file_system_instance->is_writable( $main_instance->get_tmp_path( 'fonts' ) ) ? 'ok' : 'failed',
'status_message' => $file_system_instance->is_writable( $main_instance->get_tmp_path( 'fonts' ) ) ? $status['ok'] : $status['failed'],
),
);
return (array) apply_filters(
'wpo_wcpdf_plugin_directories',
$permissions,
$status
);
}
/**
* Get the yearly reset scheduled action.
*
* @return array|false
*/
public function get_yearly_reset_schedule() {
if ( ! WPO_WCPDF()->get_instance( 'settings' )->maybe_schedule_yearly_reset_numbers() ) {
return false;
}
if ( ! function_exists( '\\as_get_scheduled_actions' ) ) {
wcpdf_log_error( 'Action Scheduler function not available. Cannot retrieve the yearly numbering reset schedule.', 'critical' );
return false;
}
$scheduled_actions = \as_get_scheduled_actions( array(
'hook' => 'wpo_wcpdf_schedule_yearly_reset_numbers',
'status' => \ActionScheduler_Store::STATUS_PENDING,
) );
if ( ! empty( $scheduled_actions ) ) {
$total_actions = count( $scheduled_actions );
if ( $total_actions === 1 ) {
$action = reset( $scheduled_actions );
$action_date = is_callable( array( $action->get_schedule(), 'get_date' ) ) ?
$action->get_schedule()->get_date() :
$action->get_schedule()->get_next( \as_get_datetime_object() );
$yearly_reset = array(
'value' => sprintf(
/* translators: %s action date */
__( 'Scheduled to: %s', 'woocommerce-pdf-invoices-packing-slips' ),
gmdate( wcpdf_date_format( null, 'yearly_reset_schedule' ), $action_date->getTimestamp() )
),
'result' => true,
);
} else {
$yearly_reset = array(
'value' => sprintf(
/* translators: total scheduled actions */
__( 'Only 1 scheduled action should exist, but %s were found', 'woocommerce-pdf-invoices-packing-slips' ),
$total_actions
),
'result' => false,
);
}
} else {
$yearly_reset = array(
'value' => sprintf(
/* translators: 1. open anchor tag, 2. close anchor tag */
__( 'Scheduled action not found. Please reschedule it %1$shere%2$s.', 'woocommerce-pdf-invoices-packing-slips' ),
'',
' '
),
'result' => false,
);
}
return $yearly_reset;
}
/**
* Get settings sections.
*
* @return array
*/
private function get_settings_sections(): array {
return (array) apply_filters(
'wpo_wcpdf_settings_debug_sections',
array(
'settings' => __( 'Settings', 'woocommerce-pdf-invoices-packing-slips' ),
'status' => __( 'Status', 'woocommerce-pdf-invoices-packing-slips' ),
'tools' => __( 'Tools', 'woocommerce-pdf-invoices-packing-slips' ),
'numbers' => __( 'Numbers', 'woocommerce-pdf-invoices-packing-slips' ),
)
);
}
/**
* Define settings categories for the Advanced tab.
*
* @return array
*/
public function get_settings_categories(): array {
$categories = array(
'filesystem_access' => array(
'title' => __( 'File System & Access', 'woocommerce-pdf-invoices-packing-slips' ),
'members' => array(
'file_system_method',
'document_link_access_type',
'document_link_access_type_table',
'document_access_denied_redirect_page',
'document_custom_redirect_page',
),
),
'display_interaction' => array(
'title' => __( 'Document Display & Interaction', 'woocommerce-pdf-invoices-packing-slips' ),
'members' => array(
'pretty_document_links',
'disable_preview',
'embed_images',
'allowed_remote_hosts',
'html_output',
),
),
'document_management' => array(
'title' => __( 'Document Management & Behavior', 'woocommerce-pdf-invoices-packing-slips' ),
'members' => array(
'calculate_document_numbers',
'enable_document_data_editing',
'default_manual_document_number',
'enable_cleanup',
),
),
'localization_translation' => array(
'title' => __( 'Localization & Translation', 'woocommerce-pdf-invoices-packing-slips' ),
'members' => array(
'reload_attachment_translations',
'log_missing_translations',
),
),
'debugging_logging' => array(
'title' => __( 'Debugging & Logging', 'woocommerce-pdf-invoices-packing-slips' ),
'members' => array(
'enable_debug',
'log_to_order_notes',
'semaphore_logs',
),
),
'versioning_stability' => array(
'title' => __( 'Versioning & Stability', 'woocommerce-pdf-invoices-packing-slips' ),
'members' => array(
'check_unstable_versions',
),
),
'advanced_experimental' => array(
'title' => __( 'Advanced / Experimental', 'woocommerce-pdf-invoices-packing-slips' ),
'members' => array(
'enable_danger_zone_tools',
),
),
);
return (array) apply_filters(
'wpo_wcpdf_settings_debug_categories',
$categories
);
}
/**
* Fetch number table data
*
* @param string $table_name
* @param string $orderby
* @param string $order
* @param string $from
* @param string $to
* @param integer $chunk_size
* @param integer $offset
*
* @return void
*/
public function fetch_number_table_data( string $table_name, string $orderby = 'id', string $order = 'desc', string $from = '', string $to = '', int $chunk_size = 100, int $offset = 0 ): void {
global $wpdb;
$input_data = array(
'table_name' => $table_name,
'orderby' => $orderby,
'order' => $order,
'from' => $from,
'to' => $to,
);
$data = $this->filter_fetch_request_data( $input_data );
if ( empty( $data['table_name'] ) || empty( $data['from'] ) || empty( $data['to'] ) ) {
return;
}
$offset = absint( $offset ?? 0 );
$chunk_size = absint( $chunk_size ?? 100 );
$option_name = "wpo_wcpdf_number_data::{$data['table_name']}";
$results = get_option( $option_name, array() );
$hook = 'wpo_wcpdf_number_table_data_fetch';
$order = ( 'DESC' === strtoupper( $data['order'] ) ) ? 'DESC' : 'ASC';
$table_name = $data['table_name'];
$orderby = $data['orderby'];
$query = wpo_wcpdf_prepare_identifier_query(
"SELECT * FROM %i WHERE date BETWEEN %s AND %s ORDER BY %i $order LIMIT %d OFFSET %d",
array( $table_name, $orderby ),
array( $data['from'], $data['to'], $chunk_size, $offset )
);
$chunk_results = $wpdb->get_results( $query ); // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.NotPrepared
if ( empty( $chunk_results ) ) {
// This fetch is complete; leave queued fetches for other stores untouched.
update_option( $option_name . '::last_time', time() );
return; // exit if no more results
}
$results = array_merge( $results, $chunk_results ); // append the chunk results to the main results array
update_option( $option_name, $results );
$offset += $chunk_size; // increase the offset for the next chunk
$args = array(
'table_name' => $data['table_name'],
'orderby' => $data['orderby'],
'order' => $data['order'],
'from' => $data['from'],
'to' => $data['to'],
'chunk_size' => $chunk_size,
'offset' => $offset,
);
if ( function_exists( '\\as_enqueue_async_action' ) ) {
\as_enqueue_async_action( $hook, $args );
} else {
wcpdf_log_error( 'Action Scheduler function not available. Cannot queue next number table data fetch.', 'critical' );
}
}
/**
* Handle AJAX number table data request
*
* @return void
*/
public function ajax_numbers_data(): void {
if ( ! \WPO_WCPDF()->get_instance( 'settings' )->user_can_manage_settings() ) {
$message = __( 'You are not allowed to perform this action.', 'woocommerce-pdf-invoices-packing-slips' );
wp_send_json_error( compact( 'message' ) );
}
check_ajax_referer( 'wpo_wcpdf_debug_nonce', 'nonce' );
$request = stripslashes_deep( $_POST );
if ( isset( $request['action'] ) && 'wpo_wcpdf_numbers_data' === $request['action'] && isset( $request['operation'] ) && isset( $request['table_name'] ) ) {
$data = $this->filter_fetch_request_data( $request );
$this->delete_number_table_data( $data['table_name'] ); // both operations require delete
if ( 'fetch' === $request['operation'] ) {
$this->fetch_number_table_data( $data['table_name'], $data['orderby'], $data['order'], $data['from'], $data['to'] );
}
wp_send_json_success( array( esc_url_raw( admin_url( 'admin.php?page=wpo_wcpdf_options_page&tab=debug§ion=numbers&orderby=' . $data['orderby'] . '&order=' . $data['order'] . '&table_name=' . $data['table_name'] ) ) ) );
} else {
wp_send_json_error( array( __( 'Invalid request', 'woocommerce-pdf-invoices-packing-slips' ) ) );
}
}
/**
* Filter data from number table request
*
* @param array $request_data
* @return array
*/
public function filter_fetch_request_data( array $request_data ): array {
// Helper to check if a string already contains a time component
$contains_time = function( $str ) {
// Look for HH:MM:SS pattern anywhere in the string
return (bool) preg_match( '/\d{2}:\d{2}:\d{2}/', $str );
};
// Validate and sanitize table_name
$valid_table_name = null;
if (
isset( $request_data['table_name'] )
&& in_array( $request_data['table_name'], array_keys( $this->get_number_store_tables() ), true )
) {
$valid_table_name = sanitize_text_field( $request_data['table_name'] );
}
// Validate and sanitize order
$valid_order = 'desc';
if (
isset( $request_data['order'] )
&& in_array( strtolower( $request_data['order'] ), array( 'desc', 'asc' ), true )
) {
$valid_order = sanitize_text_field( strtolower( $request_data['order'] ) );
}
// Validate and sanitize orderby
$valid_orderby = 'id';
if (
isset( $request_data['orderby'] )
&& in_array( strtolower( $request_data['orderby'] ), array( 'id' ), true )
) {
$valid_orderby = sanitize_text_field( strtolower( $request_data['orderby'] ) );
}
// Handle "from" date
$valid_from = null;
if ( isset( $request_data['from'] ) && ! empty( $request_data['from'] ) ) {
$temp_from = esc_attr( $request_data['from'] );
if ( ! $contains_time( $temp_from ) ) {
$temp_from .= ' 00:00:00';
}
$valid_from = $temp_from;
}
// Handle "to" date
$valid_to = null;
if ( isset( $request_data['to'] ) && ! empty( $request_data['to'] ) ) {
$temp_to = esc_attr( $request_data['to'] );
if ( ! $contains_time( $temp_to ) ) {
$temp_to .= ' 23:59:59';
}
$valid_to = $temp_to;
}
return array(
'table_name' => $valid_table_name,
'order' => $valid_order,
'orderby' => $valid_orderby,
'from' => $valid_from,
'to' => $valid_to,
);
}
/**
* Delete number table cached data
*
* @param string $table_name
*
* @return void
*/
public function delete_number_table_data( string $table_name ): void {
if ( empty( $table_name ) ) {
return;
}
delete_option( "wpo_wcpdf_number_data::{$table_name}" );
delete_option( "wpo_wcpdf_number_data::{$table_name}::last_time" );
}
/**
* Search for number in number table data
*
* @param string $table_name
* @param int $search
*
* @return array
*/
public function search_number_in_table_data( string $table_name, int $search ): array {
if ( empty( $table_name ) ) {
return array();
}
$option_name = "wpo_wcpdf_number_data::{$table_name}";
$results = get_option( $option_name, array() );
$search = ! empty( $search ) ? absint( $search ) : false;
$found = array();
if ( ! empty( $results ) ) {
foreach ( $results as $result ) {
if ( absint( $result->id ) === $search ) {
$found[] = $result;
break;
}
}
}
// number not found in cached data, try directly
if ( empty( $found ) ) {
$found = $this->search_number_in_database_table( $table_name, $search );
}
return $found;
}
/**
* Search for number in number table database.
*
* @param string $table_name
* @param int $search
*
* @return array|false
*/
public function search_number_in_database_table( string $table_name, int $search ) {
global $wpdb;
if (
empty( $search ) ||
empty( $table_name ) ||
! in_array( $table_name, array_keys( $this->get_number_store_tables() ), true )
) {
return array();
}
$search = absint( $search );
$query = wpo_wcpdf_prepare_identifier_query(
"SELECT * FROM %i WHERE id = %d",
array( $table_name ),
array( $search )
);
// phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.NotPrepared
return $wpdb->get_results( $query );
}
/**
* Sort number table data
*
* @param array $results
* @param string $order
* @param string $orderby
*
* @return array
*/
public function sort_number_table_data( array $results, string $order, string $orderby ): array {
if ( empty( $results ) ) {
return $results;
}
usort( $results, function( $a, $b ) use ( $orderby, $order ) {
$orderby = esc_attr( $orderby );
$order = esc_attr( $order );
switch ( $orderby ) {
case 'id':
if ( 'desc' === $order ) {
return absint( $b->id ) - absint( $a->id );
} else {
return absint( $a->id ) - absint( $b->id );
}
break;
default:
if ( 'desc' === $order ) {
return strcmp( $b->$orderby, $a->$orderby );
} else {
return strcmp( $a->$orderby, $b->$orderby );
}
break;
}
} );
return $results;
}
/**
* Schedule or unschedule the daily unstable version check using Action Scheduler.
*
* @return void
*/
public function maybe_schedule_unstable_version_check(): void {
$hook = 'wpo_wcpdf_check_unstable_version_daily';
$debug_settings = WPO_WCPDF()->get_instance( 'settings' )->get_settings( 'debug' );
$enabled = isset( $debug_settings['check_unstable_versions'] );
if (
! function_exists( '\\as_next_scheduled_action' ) ||
! function_exists( '\\as_unschedule_all_actions' ) ||
! function_exists( '\\as_schedule_recurring_action' )
) {
wcpdf_log_error( 'Action Scheduler functions not available. Cannot schedule or unschedule the daily unstable version check.', 'critical' );
return;
}
// Unschedule all pending actions
if ( ! $enabled ) {
if ( \as_next_scheduled_action( $hook ) ) {
\as_unschedule_all_actions( $hook );
}
return;
}
// Schedule the action if not already scheduled
if ( ! \as_next_scheduled_action( $hook ) ) {
\as_schedule_recurring_action( time(), DAY_IN_SECONDS, $hook );
}
}
/**
* Run the daily check for unstable versions.
*
* @return void
*/
public function run_unstable_version_check(): void {
wpo_wcpdf_get_latest_releases_from_github();
}
/**
* Generate and download the plugin report as a PDF.
*
* @return void
*/
public function ajax_plugin_report(): void {
$settings_instance = \WPO_WCPDF()->get_instance( 'settings' );
if ( ! $settings_instance->user_can_manage_settings() ) {
wp_die( esc_html__( 'You are not allowed to perform this action.', 'woocommerce-pdf-invoices-packing-slips' ) );
}
check_ajax_referer( 'wpo_ips_plugin_report', 'nonce' );
$include_sensitive = isset( $_GET['include_sensitive'] )
? filter_var( wp_unslash( $_GET['include_sensitive'] ), FILTER_VALIDATE_BOOLEAN )
: false;
$output_html = isset( $_GET['output_html'] )
? filter_var( wp_unslash( $_GET['output_html'] ), FILTER_VALIDATE_BOOLEAN )
: false;
$report_title = 'PDF Invoices & Packing Slips for WooCommerce - Report';
$premium_plugins = $this->get_premium_plugins();
$free_extensions = $this->get_free_extensions();
$multilingual_plugins = $this->get_multilingual_plugins();
$plugin_version = \WPO_WCPDF()->version;
$store_url = get_site_url();
$report_date = gmdate( 'Y-m-d H:i:s' );
$report_user = $include_sensitive ? wp_get_current_user() : null;
$server_configs = $this->get_server_config();
$dir_permissions = $include_sensitive ? $this->get_directory_permissions() : array();
$yearly_reset = $this->get_yearly_reset_schedule();
// Load CSS file contents
$report_css = '';
$suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
$css_path = \WPO_WCPDF()->plugin_path() . '/assets/css/plugin-report' . $suffix . '.css';
$file_system_instance = \WPO_WCPDF()->get_instance( 'file_system' );
if ( $file_system_instance->exists( $css_path ) && $file_system_instance->is_readable( $css_path ) ) {
$report_css = $file_system_instance->get_contents( $css_path );
}
// Load Settings
$general_settings = get_option( 'wpo_wcpdf_settings_general', array() );
$debug_settings = get_option( 'wpo_wcpdf_settings_debug', array() );
$edi_settings = get_option( 'wpo_ips_edi_settings', array() );
$documents_settings = array();
$all_documents = \WPO_WCPDF()->get_instance( 'documents' )->get_documents( 'all' );
if ( ! empty( $all_documents ) ) {
foreach ( $all_documents as $document ) {
$document_type = $document->get_type();
$documents_settings[ $document_type ] = $settings_instance->get_document_settings( $document_type, 'pdf' );
}
}
// Logs
$logs_data = $include_sensitive ? $this->get_recent_logs() : array();
// Extensions Settings
$extensions_settings = apply_filters( 'wpo_ips_get_extensions_settings_for_report', array(), $include_sensitive );
ob_start();
include \WPO_WCPDF()->plugin_path() . '/views/plugin-report.php';
$report_html = ob_get_clean();
if ( $output_html ) {
echo $report_html; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
die();
}
$pdf_settings = array(
'paper_size' => 'A4',
'paper_orientation' => 'portrait',
'font_subsetting' => false,
);
$pdf_maker = \wcpdf_get_pdf_maker( $report_html, $pdf_settings, $this );
$pdf = $pdf_maker->output();
$filename = 'plugin-report-' . gmdate( 'Y-m-d' ) . '.pdf';
\wcpdf_pdf_headers( $filename, 'download', $pdf );
echo $pdf; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
exit();
}
/**
* Keep only valid domain names in the allowed remote hosts setting.
*
* @param mixed $value Debug settings being saved.
* @return mixed
*/
public function normalize_allowed_remote_hosts( $value ) {
if ( is_array( $value ) && isset( $value['allowed_remote_hosts'] ) && is_string( $value['allowed_remote_hosts'] ) ) {
$rejected = array();
$value['allowed_remote_hosts'] = implode( "\n", wpo_ips_normalize_remote_hosts( $value['allowed_remote_hosts'], $rejected ) );
if ( ! empty( $rejected ) && function_exists( 'add_settings_error' ) ) {
add_settings_error(
'wpo_wcpdf_settings_debug',
'wpo_ips_invalid_remote_hosts',
'' . sprintf(
/* translators: %s: comma-separated list of invalid entries. */
esc_html__( 'These entries were ignored in Allowed image hosts: %s. Enter exact hostnames such as cdn.example.com. Wildcards, leading-dot notation, IP addresses, and localhost are not supported.', 'woocommerce-pdf-invoices-packing-slips' ),
'' . esc_html( implode( ', ', array_unique( $rejected ) ) ) . ' '
) . ' ',
'warning'
);
}
}
return $value;
}
/**
* Generate and store a new random string for the temporary folder.
*
* @param array $data Request data.
* @return void
* @see ajax_process_settings_debug_tools()
*/
private function generate_random_string( array $data ): void {
$new_path = WPO_WCPDF()->get_instance( 'main' )->regenerate_random_string( true );
$message = esc_html__( 'Temporary folder moved to', 'woocommerce-pdf-invoices-packing-slips' ) . ': ' . wp_normalize_path( $new_path );
wcpdf_log_error( $message, 'info' );
wp_send_json_success( compact( 'message' ) );
}
/**
* Install fonts by triggering the font installation process in the main class.
*
* @param array $data
* @return void
* @see ajax_process_settings_debug_tools()
*/
private function install_fonts( array $data ): void {
WPO_WCPDF()->get_instance( 'main' )->maybe_reinstall_fonts( true );
$message = esc_html__( 'Fonts reinstalled!', 'woocommerce-pdf-invoices-packing-slips' );
wcpdf_log_error( $message, 'info' );
wp_send_json_success( compact( 'message' ) );
}
/**
* Reset the number sequence for a specific document type.
*
* @param array $data
* @return void
* @see ajax_process_settings_debug_tools()
*/
private function reschedule_yearly_reset( array $data ): void {
WPO_WCPDF()->get_instance( 'settings' )->schedule_yearly_reset_numbers();
$message = esc_html__( 'Yearly reset numbering system rescheduled!', 'woocommerce-pdf-invoices-packing-slips' );
wcpdf_log_error( $message, 'info' );
wp_send_json_success( compact( 'message' ) );
}
/**
* Clear temporary files that are older than the defined threshold.
*
* @param array $data
* @return void
* @see ajax_process_settings_debug_tools()
*/
private function clear_tmp( array $data ): void {
$output = WPO_WCPDF()->get_instance( 'main' )->temporary_files_cleanup( time() );
$message = reset( $output );
switch ( key( $output ) ) {
case 'error':
wcpdf_log_error( $message );
wp_send_json_error( compact( 'message' ) );
break;
case 'success':
wcpdf_log_error( $message, 'info' );
wp_send_json_success( compact( 'message' ) );
break;
default:
exit;
}
}
/**
* Clear released semaphore locks.
*
* @param array $data
* @return void
* @see ajax_process_settings_debug_tools()
*/
private function clear_released_semaphore_locks( array $data ): void {
Semaphore::cleanup_released_locks();
$message = esc_html__( 'Released semaphore locks have been cleaned up!', 'woocommerce-pdf-invoices-packing-slips' );
wcpdf_log_error( $message, 'info' );
wp_send_json_success( compact( 'message' ) );
}
/**
* Clear released legacy semaphore locks that might be left from previous versions.
*
* @param array $data
* @return void
* @see ajax_process_settings_debug_tools()
*/
private function clear_released_legacy_semaphore_locks( array $data ): void {
Semaphore::cleanup_released_locks( true );
$message = esc_html__( 'Released legacy semaphore locks have been cleaned up!', 'woocommerce-pdf-invoices-packing-slips' );
wcpdf_log_error( $message, 'info' );
wp_send_json_success( compact( 'message' ) );
}
/**
* Clear the extensions license cache.
*
* @param array $data
* @return void
* @see ajax_process_settings_debug_tools()
*/
private function clear_extensions_license_cache( array $data ): void {
WPO_WCPDF()->get_instance( 'settings' )->get_instance( 'upgrade' )->clear_extensions_license_cache();
$message = __( "Extensions' license cache cleared successfully!", 'woocommerce-pdf-invoices-packing-slips' );
wcpdf_log_error( $message, 'info' );
wp_send_json_success( compact( 'message' ) );
}
/**
* Get the premium plugins data.
*
* @return array
*/
private function get_free_extensions(): array {
$free_extensions = apply_filters(
'wpo_ips_free_extensions',
array(
'woocommerce-pdf-ips-barcode-font/woocommerce-pdf-ips-barcode-font.php',
'woocommerce-pdf-ips-mpdf/wcpdf-mpdf.php',
'woocommerce-pdf-ips-mpdf-cjk/woocommerce-pdf-ips-cjk.php',
'woocommerce-pdf-ips-cancelled-credit-notes/woocommerce-pdf-ips-cancelled-credit-notes.php',
'woocommerce-pdf-ips-csv-exporter/woocommerce-pdf-ips-csv-exporter.php',
'woocommerce-pdf-ips-custom-font/woocommerce-pdf-ips-custom-font.php',
'woocommerce-pdf-ips-thai/woocommerce-pdf-ips-thai.php',
'woocommerce-pdf-ips-unicode/woocommerce-pdf-ips-unicode.php',
'wcpdf-taxes-summary/wcpdf-taxes-summary.php',
'wcpdf-shipping-and-fees-item/wcpdf-shipping-item.php',
'wcpdf-quotation/wcpdf-quotation.php',
)
);
$plugins_data = \wpo_ips_get_plugins_data( $free_extensions );
return (array) apply_filters(
'wpo_ips_free_extensions_data',
$plugins_data
);
}
/**
* Get multilingual plugins data.
*
* @return array
*/
private function get_multilingual_plugins(): array {
$multilingual_plugins = apply_filters(
'wpo_ips_multilingual_plugins',
array(
'wpml-media-translation/plugin.php',
'woocommerce-multilingual/wpml-woocommerce.php',
'sitepress-multilingual-cms/sitepress.php',
'wpml-string-translation/plugin.php',
'polylang/polylang.php',
'polylang-wc/polylang-wc.php',
'polylang-pro/polylang.php',
'translatepress-multilingual/index.php',
'weglot/weglot.php',
'gtranslate/gtranslate.php',
'loco-translate/loco.php',
)
);
$plugins_data = \wpo_ips_get_plugins_data( $multilingual_plugins );
return (array) apply_filters(
'wpo_ips_multilingual_plugins_data',
$plugins_data
);
}
/**
* Get recent log excerpts for key handles.
*
* @param int $limit Number of lines per log file.
* @return array
*/
protected function get_recent_logs( int $limit = 100 ): array {
if ( ! defined( 'WC_LOG_DIR' ) || ! is_dir( WC_LOG_DIR ) ) {
return array();
}
$handles = apply_filters( 'wpo_ips_log_handles', array(
'fatal-errors',
'wpo-wcpdf',
'wpo-ips-edi',
'wpo-ips-semaphore',
) );
$results = array();
foreach ( $handles as $handle ) {
$pattern = trailingslashit( WC_LOG_DIR ) . $handle . '-*.log';
$files = glob( $pattern );
if ( empty( $files ) ) {
continue;
}
usort(
$files,
static function ( $a, $b ) {
return filemtime( $b ) <=> filemtime( $a );
}
);
$file = $files[0];
$lines = @file( $file, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES );
if ( ! is_array( $lines ) ) {
continue;
}
$total_lines = count( $lines );
if ( $limit > 0 && $total_lines > $limit ) {
$lines = array_slice( $lines, -$limit );
}
$results[ $handle ] = array(
'file' => basename( $file ),
'lines' => $lines,
);
}
return $results;
}
/**
* Get database server details.
*
* @return array{
* type: string|null,
* version: string|null,
* server_info: string|null,
* }
*/
protected function get_database_details(): array {
global $wpdb;
$type = null;
$version = null;
$server_info = null;
if ( ! isset( $wpdb ) || ! is_object( $wpdb ) ) {
return array(
'type' => null,
'version' => null,
'server_info' => null,
);
}
$server_info = is_callable( array( $wpdb, 'db_server_info' ) ) ? (string) $wpdb->db_server_info() : '';
$version = is_callable( array( $wpdb, 'db_version' ) ) ? (string) $wpdb->db_version() : '';
if ( false !== stripos( $server_info, 'MariaDB' ) ) {
$type = 'MariaDB';
} elseif ( false !== stripos( $server_info, 'SQLite' ) ) {
$type = 'SQLite';
} elseif ( false !== stripos( $server_info, 'MySQL' ) || ! empty( $version ) ) {
// Default to MySQL when using core wpdb and no MariaDB marker is present.
$type = 'MySQL';
}
// Fallback for SQLite integrations that may not expose db_server_info cleanly.
if ( empty( $type ) && method_exists( $wpdb, 'get_var' ) ) {
$sqlite_version = $wpdb->get_var( 'SELECT sqlite_version()' ); // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching
if ( ! empty( $sqlite_version ) ) {
$type = 'SQLite';
$version = $version ?: (string) $sqlite_version;
}
}
return array(
'type' => $type,
'version' => $version ?: null,
'server_info' => $server_info ?: null,
);
}
}
endif; // class_exists
Carabinas PCP Archives - Página 7 de 7 - Tizonniairguns, tienda de armas de aire comprimido
Inicio » Carabinas » Carabinas PCP » Página 7
Mostrando 193–206 de 206 resultados
Utilizamos cookies propias y de terceros para garantizar el funcionamiento de la web, medir su uso y mejorar nuestros servicios. Puede aceptar todas las cookies, rechazar las no necesarias o configurar sus preferencias. Política de cookies
Aceptar todo
Rechazar
Configurar
Cookies