/home/techb158/public_html/wp-content/plugins/kirki/includes/Manager
Edit: /home/techb158/public_html/wp-content/plugins/kirki/includes/Manager/PluginShortcode.php (5106B)
post_content;
// count the number of words
$words = str_word_count( wp_strip_all_tags( $thecontent ) );
// rounding off and deviding per 200 words per minute
$m = floor( $words / 200 );
// rounding off to get the seconds
$s = floor( $words % 200 / ( 200 / 60 ) );
// calculate the amount of time needed to read
if ( $m == 0 ) {
return $s . 's';
} else {
return $m . 'm';
}
}
/**
* Render the shortcode
*
* @param array $atts Shortcode attributes.
* @return string
*/
public function kirki_cm_shortcode_handler( $attributes ) {
$no_data_response = '
[No Data found]';
try {
if ( ! is_array( $attributes ) ) {
$attributes = array();
}
$defaults_attrs = array(
'slug' => '',
'data' => '',
);
$atts = shortcode_atts( $defaults_attrs, $attributes );
$slug = $this->clean_shortcode_value( sanitize_text_field( $atts['slug'] ) );
$data = $this->clean_shortcode_value( sanitize_text_field( $atts['data'] ) );
if ( empty( $slug ) || empty( $data ) ) {
return '
[Slug and Data attributes are required]';
}
$cm_post = get_page_by_path( $slug, OBJECT, KIRKI_CONTENT_MANAGER_PREFIX );
if ( ! $cm_post ) {
return $no_data_response;
}
$data = strtolower( trim( $data ) );
switch ( $data ) {
case 'count': {
return ContentManagerHelper::get_child_post_count( $cm_post->ID, array( 'publish' ) );
}
default:
return $no_data_response;
}
return $no_data_response;
} catch ( \Exception $e ) {
return $no_data_response;
}
}
/**
* Kirki shortcode handler
*
* @param array $atts Shortcode attributes.
* @return string
*/
public function kirki_shortcode_handler( $attributes ) {
$no_data_response = '
[No Data found]';
try {
if ( ! is_array( $attributes ) ) {
$attributes = array();
}
$defaults_attrs = array(
'type' => '',
'data' => '',
);
$atts = shortcode_atts( $defaults_attrs, $attributes );
$type = $this->clean_shortcode_value( sanitize_text_field( $atts['type'] ) );
$data = $this->clean_shortcode_value( sanitize_text_field( $atts['data'] ) );
$data = strtolower( trim( $data ) );
switch ( $type ) {
case 'post_meta': {
if ( is_singular() ) {
global $post;
$meta_value = get_post_meta( $post->ID, $data, true );
if ( is_string( $meta_value ) ) {
// Post meta is arbitrary, low-privilege-authored data: always escape.
return \Kirki\HelperFunctions::escape_post_meta_value( $meta_value );
}
}
return '';
}
default: {
switch ( $data ) {
case 'current_year': {
return gmdate( 'Y' );
}
case 'current_date': {
return gmdate( 'F j, Y' );
}
case 'reading_time': {
if ( is_singular() ) {
global $post;
return $this->post_estimated_reading_time( $post );
}
return $no_data_response;
}
default:
return $no_data_response;
}
return $no_data_response;
}
}
return $no_data_response;
} catch ( \Exception $e ) {
return $no_data_response;
}
}
}