' . esc_html__( 'About', 'custom-post-type-ui' ) . '',
'' . esc_html__( 'Help', 'custom-post-type-ui' ) . '',
),
$links
);
}
add_filter( 'plugin_action_links_' . plugin_basename( dirname( __DIR__ ) ) . '/custom-post-type-ui.php', 'cptui_edit_plugin_list_links' );
/**
* Returns SVG icon for custom menu icon
*
* @since 1.2.0
*
* @return string
*/
function cptui_menu_icon() {
return 'dashicons-forms';
}
/**
* Return boolean status depending on passed in value.
*
* @since 0.5.0
*
* @param mixed $bool_text text to compare to typical boolean values.
* @return bool Which bool value the passed in value was.
*/
function get_disp_boolean( $bool_text ) {
$bool_text = (string) $bool_text;
if ( empty( $bool_text ) || '0' === $bool_text || 'false' === $bool_text ) {
return false;
}
return true;
}
/**
* Return string versions of boolean values.
*
* @since 0.1.0
*
* @param string $bool_text String boolean value.
* @return string standardized boolean text.
*/
function disp_boolean( $bool_text ) {
$bool_text = (string) $bool_text;
if ( empty( $bool_text ) || '0' === $bool_text || 'false' === $bool_text ) {
return 'false';
}
return 'true';
}
/**
* Display footer links and plugin credits.
*
* @since 0.3.0
*
* @internal
*
* @param string $original Original footer content. Optional. Default empty string.
* @return string $value HTML for footer.
*/
function cptui_footer( $original = '' ) {
$screen = get_current_screen();
if ( ! is_object( $screen ) || 'cptui_main_menu' !== $screen->parent_base ) {
return $original;
}
return sprintf(
// translators: Placeholder will hold the name of the plugin, version of the plugin and a link to WebdevStudios.
esc_attr__( '%1$s version %2$s by %3$s', 'custom-post-type-ui' ),
esc_attr__( 'Custom Post Type UI', 'custom-post-type-ui' ),
CPTUI_VERSION,
'WebDevStudios'
) . ' - ' .
sprintf(
// translators: Placeholders are just for HTML markup that doesn't need translated.
'%s',
esc_attr__( 'Support forums', 'custom-post-type-ui' )
) . ' - ' .
sprintf(
// translators: Placeholders are just for HTML markup that doesn't need translated.
'%s',
sprintf(
// translators: Placeholder will hold `` tag for CPTUI.
esc_attr__( 'Review %s', 'custom-post-type-ui' ),
sprintf(
// translators: Placeholders are just for HTML markup that doesn't need translated.
'%s',
esc_attr__( 'Custom Post Type UI', 'custom-post-type-ui' ),
'CPTUI'
)
)
) . ' - ' .
esc_attr__( 'Follow on X:', 'custom-post-type-ui' ) .
sprintf(
// translators: Placeholders are just for HTML markup that doesn't need translated.
' %s',
'WebDevStudios'
);
}
add_filter( 'admin_footer_text', 'cptui_footer' );
/**
* Conditionally flushes rewrite rules if we have reason to.
*
* @since 1.3.0
*/
function cptui_flush_rewrite_rules() {
if ( wp_doing_ajax() ) {
return;
}
/*
* Wise men say that you should not do flush_rewrite_rules on init or admin_init. Due to the nature of our plugin
* and how new post types or taxonomies can suddenly be introduced, we need to...potentially. For this,
* we rely on a short lived transient. Only 5 minutes life span. If it exists, we do a soft flush before
* deleting the transient to prevent subsequent flushes. The only times the transient gets created, is if
* post types or taxonomies are created, updated, deleted, or imported. Any other time and this condition
* should not be met.
*/
$flush_it = get_transient( 'cptui_flush_rewrite_rules' );
if ( 'true' === $flush_it ) {
flush_rewrite_rules( false );
// So we only run this once.
delete_transient( 'cptui_flush_rewrite_rules' );
}
}
add_action( 'admin_init', 'cptui_flush_rewrite_rules' );
/**
* Return the current action being done within CPTUI context.
*
* @since 1.3.0
*
* @return string Current action being done by CPTUI
*/
function cptui_get_current_action() {
$current_action = '';
if ( ! empty( $_GET ) && isset( $_GET['action'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification
$current_action .= esc_textarea( wp_unslash( $_GET['action'] ) ); // phpcs:ignore
}
return $current_action;
}
/**
* Return an array of all post type slugs from Custom Post Type UI.
*
* @since 1.3.0
*
* @return array CPTUI post type slugs.
*/
function cptui_get_post_type_slugs() {
$post_types = get_option( 'cptui_post_types' );
if ( ! empty( $post_types ) ) {
return array_keys( $post_types );
}
return [];
}
/**
* Return an array of all taxonomy slugs from Custom Post Type UI.
*
* @since 1.3.0
*
* @return array CPTUI taxonomy slugs.
*/
function cptui_get_taxonomy_slugs() {
$taxonomies = get_option( 'cptui_taxonomies' );
if ( ! empty( $taxonomies ) ) {
return array_keys( $taxonomies );
}
return [];
}
/**
* Return the appropriate admin URL depending on our context.
*
* @since 1.3.0
*
* @param string $path URL path.
* @return string
*/
function cptui_admin_url( $path ) {
if ( is_multisite() && is_network_admin() ) {
return network_admin_url( $path );
}
return admin_url( $path );
}
/**
* Construct action tag for `