nt( $results );
if ( $count_results ) {
$total_records += $count_results;
if ( is_callable( $callback ) ) {
call_user_func( $callback, $results );
}
if ( $count_results < $query_limit ) {
break;
}
} else {
break;
}
}
}
}
if ( ! function_exists( 'us_get_used_in_locations' ) ) {
/**
* Generate all locations names where used specific element
*
* @param array $post_ID
* @param bool $show_no_results
* @return array
*/
function us_get_all_used_in_locations( $post_IDs, $show_no_results = FALSE ) {
if ( empty( $post_IDs ) OR ! is_array( $post_IDs ) ) {
return array();
}
$ids = array_unique( array_map( 'intval', $post_IDs ) );
static $results = array();
$is_empty_result = FALSE;
foreach ( $ids as $id ) {
if ( ! isset( $results[ $id ] ) ) {
$is_empty_result = TRUE;
break;
}
}
if ( $is_empty_result ) {
global $usof_options, $wpdb;
usof_load_options_once();
$used_in = $posts_types = array();
$areas = array(
'header' => '',
'titlebar' => ' > ' . __( 'Titlebar', 'us' ),
'sidebar' => ' > ' . __( 'Sidebar', 'us' ),
'content' => '',
'footer' => ' > ' . __( 'Footer', 'us' ),
);
foreach ( $ids as $id ) {
$used_in[ $id ] = array(
'theme_options' => array(),
'singulars_meta' => array(),
'singulars_content' => array(),
'nav_menu_item' => array(),
);
$results[ $id ] = '';
$posts_types[ $id ] = get_post_type( $id );
}
// Theme Options > Pages Layout
foreach ( us_get_public_post_types( /* exclude */'product' ) as $type => $title ) {
// Fix suffixes regarding historical theme options names
switch ( $type ) {
case 'page':
$type = '';
break;
case 'us_portfolio':
$type = '_portfolio';
break;
default:
$type = '_' . $type;
break;
}
$link_atts = array(
'href' => admin_url( 'admin.php?page=us-theme-options#pages_layout' ),
'target' => '_blank',
);
$edit_link = ' (' . __( 'edit in Theme Options', 'us' ) . ')';
foreach ( $ids as $id ) {
foreach ( $areas as $area => $area_name ) {
if ( isset( $usof_options[ $area . $type . '_id' ] ) AND $usof_options[ $area . $type . '_id' ] == $id ) {
$used_in[ $id ]['theme_options'][] = '
' . $title . $area_name . '' . $edit_link;
}
}
}
}
}
// Append locations to result string
foreach ( $ids as $id ) {
$results[ $id ] .= implode( $used_in[ $id ]['theme_options'] );
}
// Singulars (metabox)
if ( ! empty( $areas ) ) {
$usage_meta_keys = array_map(
function ( $area ) {
return sprintf( 'us_%s_id', $area );
}, array_keys( $areas )
);
$query = "
SELECT
pm.post_id, pm.meta_key, pm.meta_value,
p.post_title
FROM {$wpdb->postmeta} AS pm
LEFT JOIN {$wpdb->posts} AS p
ON pm.post_id = p.ID
WHERE
pm.meta_value IN( '" . implode( "','", $ids ) . "' )
AND pm.meta_key IN( '" . implode( "','", $usage_meta_keys ) . "' )";
// Iterate queries
us_iterate_queries(
$query,
function ( $items ) use ( &$used_in, $areas ) {
foreach ( $items as $item ) {
if (
is_null( $item->post_title )
OR ! us_is_post_visible_for_curr_lang( $item->post_id, $item->meta_value )
) {
continue;
}
// Get post title
$post_title = empty( $item->post_title )
? us_translate( '(no title)' )
: $item->post_title;
// Get post link atts
$link_atts = array(
'href' => us_get_edit_post_link( $item->post_id ),
'target' => '_blank',
'title' => us_translate( 'View Page' ),
);
$used_in[ $item->meta_value ]['singulars_meta'][] = '
';
}
}
);
}
// Append locations to result string
foreach ( $ids as $id ) {
$results[ $id ] .= implode( $used_in[ $id ]['singulars_meta'] );
}
// Singulars (content)
$meta_value_like = '';
foreach ( $ids as $id ) {
if ( ! empty( $meta_value_like ) ) {
$meta_value_like .= ' OR';
}
$meta_value_like .= " meta_value LIKE '%" . $id . "%'";
}
$query = "
SELECT
pm.post_id, pm.meta_value,
p.post_title, p.post_type
FROM {$wpdb->postmeta} AS pm
LEFT JOIN {$wpdb->posts} AS p
ON pm.post_id = p.ID
WHERE
meta_key = '_us_in_content_ids'
AND ({$meta_value_like})
";
// Iterate queries
us_iterate_queries(
$query,
function ( $items ) use ( &$used_in, $ids, $posts_types ) {
foreach ( $items as $item ) {
if ( ! $post_id = $item->post_id ) {
continue;
}
$meta_value_ids = explode( ',', $item->meta_value );
foreach ( $ids as $id ) {
if (
in_array( $id, $meta_value_ids )
AND us_is_post_visible_for_curr_lang( $post_id, $id )
) {
$used_in[ $id ]['singulars_content'][ $post_id ] = array(
'url' => us_get_edit_post_link( $post_id ),
'edit_url' => us_get_edit_post_link( $post_id, $item->post_type ),
'title' => empty( $item->post_title )
? us_translate( '(no title)' )
: $item->post_title,
'post_type' => ! empty( $posts_types[ $id ] )
? $posts_types[ $id ]
: NULL,
);
}
}
}
}
);
// Append locations to result string
foreach ( $ids as $id ) {
if ( ! empty( $used_in[ $id ] ) AND ! empty( $used_in[ $id ]['singulars_content'] ) ) {
foreach ( $used_in[ $id ]['singulars_content'] as $location ) {
switch ( $location['post_type'] ) {
case 'us_page_block':
$url = $location['edit_url'];
$title = __( 'Edit Reusable Block', 'us' );
break;
case 'us_content_template':
$url = $location['edit_url'];
$title = __( 'Edit Page Template', 'us' );
break;
default:
$url = $location['url'];
$title = us_translate( 'View Page' );
break;
}
$link_atts = array(
'href' => $url,
'target' => '_blank',
'title' => $title,
);
$results[ $id ] .= '
';
}
}
}
// Widgets (for Grid Layouts only)
$regexp_layouts = array();
foreach ( $ids as $id ) {
$regexp_layouts[] = strlen( $id ) . ':"' . $id;
}
$regexp_layouts = implode( '|', $regexp_layouts );
$query = "
SELECT
`option_name`, `option_value`
FROM {$wpdb->options}
WHERE
option_name LIKE 'widget%'
AND option_value REGEXP '\"layout\";s:({$regexp_layouts})\"'
LIMIT 0, 100";
if ( $widget_options = $wpdb->get_results( $query ) ) {
global $wp_registered_sidebars, $wp_registered_widgets;
$_widget_titles = $_sidebars_widgets = array();
// Get widget_id => Sidebar name
foreach ( wp_get_sidebars_widgets() as $sidebar_id => $widget_ids ) {
if (
$sidebar_id === 'wp_inactive_widgets'
OR ! isset( $wp_registered_sidebars[ $sidebar_id ] )
) {
continue;
}
$_sidebars_widgets = array_merge(
$_sidebars_widgets,
array_fill_keys( array_values( $widget_ids ), $wp_registered_sidebars[ $sidebar_id ]['name'] )
);
}
// Get widget name
foreach ( $wp_registered_widgets as $base_id => $widget ) {
foreach ( $widget['callback'] as $callback ) {
if ( isset( $callback->option_name, $_sidebars_widgets[ $base_id ] ) ) {
$number = substr( $base_id, mb_strlen( $callback->id_base . '-' ) );
$_widget_titles[ $callback->option_name ][ $number ] = [
'sidebar_name' => $_sidebars_widgets[ $base_id ],
'name' => $callback->name,
];
}
}
}
unset( $_sidebars_widgets );
// Creating links for widgets
foreach ( $widget_options as $usage_result ) {
foreach ( $ids as $id ) {
foreach ( unserialize( $usage_result->option_value ) as $number => $value ) {
if ( ! is_array( $value ) OR ! isset( $value['layout'] ) OR $value['layout'] != $id ) {
continue;
}
$_widget = isset( $_widget_titles[ $usage_result->option_name ][ $number ] )
? $_widget_titles[ $usage_result->option_name ][ $number ]
: [];
$name = isset( $_widget['name'] )
? $_widget['name']
: '';
if ( ! empty( $value['title'] ) ) {
$name .= ': ' . $value['title'];
}
$sidebar_name = isset( $_widget['sidebar_name'] )
? $_widget['sidebar_name'] . ' > '
: '';
// NOTE: The widget is in the config because it is not deleted, you can find it on
// the widgets page in the "Inactive Sidebar (not used)" action, but we do not display this.
if ( empty( $sidebar_name ) ) {
continue;
}
$results[ $id ] .= '
';
unset( $_widget, $name, $sidebar_name );
}
}
}
}
$group_posts_types = array();
foreach ( $posts_types as $id => $post_type ) {
$group_posts_types[ $post_type ][] = $id;
}
/**
* Layouts for archives or taxonomies
*
* Note: Despite the fact that here the foreach receipt of data
* occurs for one type of post (the current one)
*/
foreach( array( 'us_header', 'us_content_template', 'us_page_block' ) as $us_post_type ) {
if ( ! empty( $group_posts_types[ $us_post_type ] ) ) {
// Keys from the archives or taxonomy page
$usage_meta_keys = array(
// Header
'us_header' => array(
'archive_header_id' => __( 'Archives Layout', 'us' ),
'pages_header_id' => __( 'Pages Layout', 'us' ),
),
// Page Templates
'us_content_template' => array(
'archive_content_id' => __( 'Archives Layout', 'us' ),
'pages_content_id' => __( 'Pages Layout', 'us' ),
),
// Footer
'us_page_block' => array(
'archive_footer_id' => __( 'Archives Layout', 'us' ),
'pages_footer_id' => __( 'Pages Layout', 'us' ),
),
);
$query = "
SELECT
tm.term_id, t.name, tt.taxonomy, tm.meta_key, tm.meta_value
FROM {$wpdb->termmeta} AS tm
LEFT JOIN {$wpdb->terms} AS t
ON tm.term_id = t.term_id
LEFT JOIN {$wpdb->term_taxonomy} AS tt
ON tm.term_id = tt.term_id
WHERE
tm.meta_value IN( '" . implode( "','", $group_posts_types[ $us_post_type ] ) . "' )
AND tm.meta_key IN( '" . implode( "','", array_keys( $usage_meta_keys[ $us_post_type ] ) ) . "' )
";
// Iterate queries
us_iterate_queries(
$query,
function ( $items ) use ( &$results, $group_posts_types, $usage_meta_keys, $us_post_type ) {
foreach ( $items as $item ) {
foreach ( $group_posts_types[ $us_post_type ] as $id ) {
if (
in_array( $id, explode( ',', $item->meta_value ) )
AND $tax = get_taxonomy( $item->taxonomy )
) {
$result = '
' . $tax->label . ' > ';
$result .= $item->name . ' > ';
$result .= us_translate( $usage_meta_keys[ $us_post_type ][ $item->meta_key ] ) . '';
$result .= ' (
' . us_translate( 'Edit' ) . ')
';
$results[ $id ] .= $result;
}
}
}
}
);
}
}
// Menus (nav_menu_item) for Reusable Blocks only
if ( ! empty( $group_posts_types['us_page_block'] ) ) {
$meta_value_like = '';
foreach ( $group_posts_types['us_page_block'] as $id ) {
if ( ! empty( $meta_value_like ) ) {
$meta_value_like .= ' OR';
}
$meta_value_like .= " meta1.meta_value LIKE '%" . $id . "%'";
}
$query = "
SELECT
meta1.meta_value, p.ID as post_id
FROM {$wpdb->postmeta} meta1
LEFT JOIN {$wpdb->postmeta} meta2
ON (
meta1.post_id = meta2.post_id
AND meta2.meta_key = '_menu_item_object'
AND meta2.meta_value = 'us_page_block'
)
LEFT JOIN {$wpdb->posts} AS p
ON meta1.post_id = p.ID
WHERE
meta1.meta_key = '_menu_item_object_id'
AND ({$meta_value_like})
";
// Iterate queries
us_iterate_queries(
$query,
function ( $items ) use ( &$used_in, $ids ) {
foreach ( $items as $item ) {
if ( ! $post_id = $item->post_id ) {
continue;
}
$meta_value_ids = explode( ',', $item->meta_value );
foreach ( $ids as $id ) {
if ( ! in_array( $id, $meta_value_ids ) ) {
continue;
}
$used_in[ $id ]['nav_menu_item'][ $post_id ] = wp_get_post_terms(
$post_id,
'nav_menu',
array( 'fields' => 'all' )
);
}
}
}
);
}
// Append locations to result string
foreach ( $ids as $id ) {
if ( ! empty( $used_in[ $id ] ) AND ! empty( $used_in[ $id ]['nav_menu_item'] ) ) {
foreach ( $used_in[ $id ]['nav_menu_item'] as $location ) {
if ( ! empty( $location ) ) {
$link_atts = array(
'href' => admin_url( 'nav-menus.php?action=edit&menu=' . $location[0]->term_id ),
'target' => '_blank',
'title' => us_translate( 'Edit Menu' ),
);
$results[ $id ] .= '
';
}
}
}
}
// Return "No results" message if set
foreach ( $results as &$result ) {
if ( empty( $result ) AND $show_no_results ) {
$result = us_translate( 'No results found.' );
}
}
}
return $results;
}
/**
* Generate locations names where used specific element
*
* @param int $post_ID
* @param bool $show_no_results
* @return string
*/
function us_get_used_in_locations( $post_ID, $show_no_results = FALSE ) {
$results = (array) us_get_all_used_in_locations( array( $post_ID ), $show_no_results );
return ! empty( $results[ $post_ID ] )
? $results[ $post_ID ]
: '';
}
}
5 tendências de estratégias de nuvem para 2020 – GTI Solution
[vc_row el_class="sidebar-fix" columns="3-1"][vc_column width="3/4"][us_post_title css="%7B%22default%22%3A%7B%22color%22%3A%22_content_primary%22%2C%22line-height%22%3A%221.2%22%2C%22font-family%22%3A%22Open%20Sans%22%2C%22font-weight%22%3A%22700%22%2C%22margin-bottom%22%3A%220.5rem%22%7D%7D"][us_hwrapper wrap="1"][us_post_date format="smart" text_before="Postado em" css="%7B%22default%22%3A%7B%22font-size%22%3A%220.9rem%22%7D%7D"][us_post_comments layout="amount" css="%7B%22default%22%3A%7B%22font-size%22%3A%220.9rem%22%7D%7D"][/us_hwrapper][us_separator size="small"][us_post_image media_preview="1" thumbnail_size="full" css="%7B%22default%22%3A%7B%22margin-bottom%22%3A%221.5rem%22%7D%7D"][us_post_content type="full_content"][us_separator][us_sharing providers="email,facebook,twitter,linkedin,pinterest,whatsapp,telegram" type="solid"][us_separator size="small" show_line="1"][us_post_navigation][/vc_column][vc_column width="1/4"][us_page_block id="10024" force_fullwidth_rows="1"][/vc_column][/vc_row]