: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in
function array_has_value($needle, $array) {
foreach ( $array as $value ) {
if ( trim( $needle ) == trim( $value ) ) {
function array_msort($array, $cols) {
foreach ( $cols as $col => $order ) {
foreach ( $array as $k => $row ) {
$colarr[$col]['_' . $k] = strtolower( $row[$col] );
$eval = 'array_multisort(';
foreach ( $cols as $col => $order ) {
$eval .= '$colarr[\'' . $col . '\'],' . $order . ',';
$eval = substr( $eval, 0, -1 ) . ');';
foreach ( $colarr as $col => $arr ) {
foreach ( $arr as $k => $v ) {
if ( !isset( $ret[$k] ) ) {
$ret[$k][$col] = $array[$k][$col];
function custom_sort($a, $b) {
if ( array_key_exists( 'post_date', $a ) && array_key_exists( 'post_date', $b ) ) {
return $a['post_date'] < $b['post_date'];
} else if ( array_key_exists( 'post_date', $a ) ) {
} else if ( array_key_exists( 'post_date', $b ) ) {
function format_exclusion($table_name, $column_name, $values) {
if ( is_array( $values ) ) {
$values = array_map( function ($item) use($column_name){
return "'" . esc_sql( $item[$column_name] ) . "'";
return "'" . esc_sql( $item ) . "'";
return "($table_name.$column_name NOT IN (" . join( ',', $values ) . '))';
function format_inclusion($table_name, $column_name, $values, $union = 'OR') {
if ( is_array( $values ) ) {
if ( count( $values ) > 0 ) {
$values = array_map( function ($item) use ($column_name){
return "'" . esc_sql( $item[$column_name] ) . "'";
return "'" . esc_sql( $item ) . "'";
return "($table_name.$column_name IN (" . join( ',', $values ) . '))';
foreach($values as $value){
$sql[] = "$table_name.$column_name = $value";
return join( ' AND ', $sql );
return "({$table_name}.{$column_name} = '')";
function get_letters_excerpt($length, $content, $permalink) {
$content = substr( $content, 0, intval( $length ) );
$words = explode( ' ', $content );
$content = implode( ' ', $words );
/* Original Code return $content.'... <a href="'.$permalink.'"> '.__('read more→','trans-nlp').'</a>'; */
/* Edited Code Turned argument 'read more→' to ''*/
function get_words_excerpt($length, $content, $permalink) {
$words = explode( ' ', $content );
if ( count( $words ) > $length ) {
$words = array_slice( $words, 0, $length );
$content = implode( ' ', $words );
/* Original Code return $content.'... <a href="'.$permalink.'"> '.__('read more→','trans-nlp').'</a>'; */
/* Edited Code Turned argument 'read more→' to ''*/
return $content . '... <a href="' . $permalink . '"> ' . __( '', 'trans-nlp' ) . '</a>';
$content = implode( ' ', $words );
/* Original Code return $content.' <a href="'.$permalink.'"> '.__('read more→','trans-nlp').'</a>'; */
/* Edited Code Turned argument 'read more→' to ''*/
return $content . ' <a href="' . $permalink . '"> ' . __( '', 'trans-nlp' ) . '</a>';
function netsposts_strip_text_words( string $text, int $word_count ): string {
$words = explode( ' ', $text );
if ( count( $words ) > $word_count ) {
$words = array_slice( $words, 0, $word_count );
$stripped_text = implode( ' ', $words ) . '...';
function removeElementWithValue(&$array, $key, $value) {
foreach ( $array as $subKey => $subArray ) {
if ( $subArray[$key] == $value ) {
unset( $array[$subKey] );
function sanitize_quotes($str) {
return str_replace( ''', '"', $str );
function ShortenText($text, $limit) {
$chars_text = strlen( $text );
$text = substr( $text, 0, $chars_limit );
$nearest_space_position = strrpos( $text, ' ' );
if( $nearest_space_position !== false ) {
$text = substr( $text, 0, $nearest_space_position );
if ( $chars_text > $chars_limit ) {
function shorten_text_exact( $text, $limit ) {
return mb_substr( $text, 0, $limit );
function super_unique($array, $key) {
foreach ( $array as $v ) {
if ( !isset( $temp_array[$v[$key]] ) ) {
$temp_array[$v[$key]] = $v;
$array = array_values( $temp_array );
* @param $str String representation of date or 'now'
* @return DateTime|null Returns date with time equal 00:00:00
function netsposts_strtodate($str) {
$filter_date = new DateTime( $str );
$filter_date->setTime( 0, 0, 0 );
$filter_date = new DateTime();
* @param array $src_array
* @param array $show_after_date - An array contains field name and date to filter posts after target date including today.
* @param array $show_before_date - An array contains field name and date to filter posts before target date not including today.
* @param $show_for_today - String Field name to filter posts during today.
* @return array Returns array filtered by date fields
function netsposts_filter_by_date(array $src_array, array $show_after_date = null, array $show_before_date = null, $show_for_today = null) {
$current_date = netsposts_strtodate( 'now' );
return array_filter( $src_array, function ($post) use ($show_after_date, $show_before_date, $show_for_today, $current_date) {
if ( $show_after_date ) {
if ( isset( $post[$show_after_date[0]] ) ) {
$post_after_date = netsposts_strtodate( $post[$show_after_date[0]] );
$result = $result || $post_after_date->getTimestamp() >= $show_after_date[1]->getTimestamp();
if ( $show_before_date ) {
if ( isset( $post[$show_before_date[0]] ) ) {
$post_before_date = netsposts_strtodate( $post[$show_before_date[0]] );
$result = $result || $post_before_date->getTimestamp() < $show_before_date[1]->getTimestamp();
if ( isset( $post[$show_for_today] ) ) {
$post_today_date = new DateTime( $post[$show_for_today] );
$result = $result || $post_today_date->getTimestamp() === $current_date->getTimestamp();
} catch ( Exception $e ) {
function netsposts_create_label_from_id($id) {
$fullname = str_replace( "_", " ", $id );
return strtoupper( mb_substr( $fullname, 0, 1 ) ) . mb_substr( $fullname, 1 );
function netsposts_modify_pagination($route_url, $pagination, $page) {
$escaped_route_url = str_replace( '/', '\/', $route_url );
$pagination = str_replace( "'", '"', $pagination );
$pattern = '/\b' . $escaped_route_url . '.*?\/([0-9]+)\/"/m';
$new_pagination = preg_replace( $pattern, $route_url . '$1"', $pagination );
function netsposts_filter_empty_values( array $data ): array{
return array_filter( $data, function( $item ){
function netsposts_get_post_custom_taxonomies( int $post_id ): array{
if( function_exists( 'cptui_get_taxonomy_slugs' ) ){
$custom_taxonomies = cptui_get_taxonomy_slugs();
$terms = wp_get_post_terms( $post_id, $custom_taxonomies );
if( is_array( $terms ) ){
foreach ( $terms as &$term ){
$term->url= get_term_link( $term );
function netsposts_get_post_taxonomies( int $post_id, array $types ): array {
$terms = wp_get_post_terms( $post_id, $types );
if( is_array( $terms ) ){
foreach ( $terms as &$term ){
$term->url= get_term_link( $term );
function netsposts_remove_pagination( ?string $text ): string {
if( is_null( $text ) ) return '';
$re = '/\<div\sclass\=\"netsposts-paginate\"\>.*?\<\/div\>/s';
return preg_replace( $re, '', $text );
function netsposts_get_local_fields( int $post_id ): array {
do_action( 'acf/include_fields' );
$local_fields = $acf->local->fields;
} elseif( function_exists( 'acf_get_local_fields' ) ) {
$local_fields = acf_get_local_fields();
$output_fields = array();
foreach ( $local_fields as $field ) {
$value = get_post_meta( $post_id, $field['name'], true );
$field['value'] = acf_format_value( $value, $post_id, $field );
$output_fields[ $field['name'] ] = $field;
function netsposts_replace_image_domains( string $html, string $needle, string $replacement ): string {
$needle_escaped = str_replace( '/', '\/', $needle );
$pattern = '/img.*?src=[\'"](' . $needle_escaped . '.*?)[\'"]/';
if( preg_match_all( $pattern, $html, $matches ) ){
foreach ( $matches[0] as $match ){
$replaced = str_replace( $needle, $replacement, $match );
$html = str_replace( $match, $replaced, $html );
$pattern = '/img.*?srcset=[\'"](' . $needle_escaped . '.*?)[\'"]/';
if( preg_match_all( $pattern, $html, $matches ) ){
foreach ( $matches[0] as $match ){
$replaced = str_replace( $needle, $replacement, $match );
$html = str_replace( $match, $replaced, $html );
function netsposts_replace_image_link_domains( string $html, string $needle, string $replacement ): string {
$needle_escaped = str_replace( '/', '\/', $needle );
$needle_escaped = str_replace( '.', '\.', $needle_escaped );
$pattern = '/a.*?href\=[\'"](' . $needle_escaped . '.*?)[\'"].*?\>\s*\<img/';
if( preg_match_all( $pattern, $html, $matches ) ){
foreach ( $matches[0] as $match ){
$replaced = str_replace( $needle, $replacement, $match );
$html = str_replace( $match, $replaced, $html );
function display_var( $var ): void {
if( isset( $GLOBALS['NETSPOSTS_DEBUG'] ) &&
$GLOBALS['NETSPOSTS_DEBUG'] && ! is_admin() ) {
function display_string( $str ): void {
if( isset( $GLOBALS['NETSPOSTS_DEBUG'] ) &&
$GLOBALS['NETSPOSTS_DEBUG'] && ! is_admin() ) {