$value ) { $shortcode = str_replace( '%%' . $key . '%%', esc_attr( $value ), $shortcode ); } return $shortcode; } /** * Generate a unique slug * * @param $slug * * @return string */ function sh_cd_slug_generate( $slug, $exising_id = NULL ) { if ( true === empty( $slug ) ) { return NULL; } $slug = sanitize_key( $slug ); $original_slug = $slug; $try = 1; // Ensure the slug is unique while ( false === sh_cd_slug_is_unique( $slug, $exising_id ) ) { $slug = sprintf( '%s_%d', $original_slug, $try ); $try++; } return $slug; } /** * Clone an existing shortcode! * * @param $id * * @return bool */ function sh_cd_clone( $id ) { if( false === sh_cd_is_premium() ) { return true; } if ( false === is_numeric( $id ) ) { return false; } $to_be_cloned = sh_cd_db_shortcodes_by_id( $id ); if ( true === empty( $to_be_cloned ) ) { return false; } unset( $to_be_cloned['id'] ); return sh_cd_db_shortcodes_save( $to_be_cloned ); } /** * Display message in admin UI * * @param $text * @param bool $error */ function sh_cd_message_display( $text, $error = false ) { if ( true === empty( $text ) ) { return; } printf( '
%s