codepress-admin-columns
Last commit date
assets
8 years ago
classes
8 years ago
external
8 years ago
languages
8 years ago
templates
8 years ago
api.php
8 years ago
codepress-admin-columns.php
8 years ago
readme.txt
8 years ago
api.php
172 lines
| 1 | <?php |
| 2 | |
| 3 | if ( ! defined( 'ABSPATH' ) ) { |
| 4 | exit; |
| 5 | } |
| 6 | |
| 7 | /** |
| 8 | * @return bool True when Admin Columns Pro plugin is activated. |
| 9 | */ |
| 10 | function ac_is_pro_active() { |
| 11 | return function_exists( 'ACP' ); |
| 12 | } |
| 13 | |
| 14 | /** |
| 15 | * Get the url where the Admin Columns website is hosted |
| 16 | * |
| 17 | * @return string |
| 18 | */ |
| 19 | function ac_get_site_url( $path = '' ) { |
| 20 | $url = 'https://www.admincolumns.com'; |
| 21 | |
| 22 | if ( ! empty( $path ) ) { |
| 23 | $url .= '/' . trim( $path, '/' ) . '/'; |
| 24 | } |
| 25 | |
| 26 | return $url; |
| 27 | } |
| 28 | |
| 29 | /** |
| 30 | * Url with utm tags |
| 31 | * |
| 32 | * @param string $path |
| 33 | * @param string $utm_medium |
| 34 | * @param string $utm_content |
| 35 | * |
| 36 | * @return string |
| 37 | */ |
| 38 | function ac_get_site_utm_url( $path, $utm_medium, $utm_content = null, $utm_campaign = false ) { |
| 39 | $url = ac_get_site_url( $path ); |
| 40 | |
| 41 | if ( ! $utm_campaign ) { |
| 42 | $utm_campaign = 'plugin-installation'; |
| 43 | } |
| 44 | |
| 45 | $args = array( |
| 46 | // Referrer: plugin |
| 47 | 'utm_source' => 'plugin-installation', |
| 48 | |
| 49 | // Specific promotions or sales |
| 50 | 'utm_campaign' => $utm_campaign, |
| 51 | |
| 52 | // Marketing medium: banner, documentation or email |
| 53 | 'utm_medium' => $utm_medium, |
| 54 | |
| 55 | // Used for differentiation of medium |
| 56 | 'utm_content' => $utm_content, |
| 57 | ); |
| 58 | |
| 59 | $args = array_map( 'sanitize_key', array_filter( $args ) ); |
| 60 | |
| 61 | return add_query_arg( $args, $url ); |
| 62 | } |
| 63 | |
| 64 | /** |
| 65 | * Admin Columns Twitter username |
| 66 | * |
| 67 | * @return string |
| 68 | */ |
| 69 | function ac_get_twitter_handle() { |
| 70 | return 'admincolumns'; |
| 71 | } |
| 72 | |
| 73 | /** |
| 74 | * Simple helper methods for AC_Column objects |
| 75 | * |
| 76 | * @since 3.0 |
| 77 | */ |
| 78 | function ac_helper() { |
| 79 | return AC()->helper(); |
| 80 | } |
| 81 | |
| 82 | /** |
| 83 | * @since 3.0 |
| 84 | * @return bool True when a minimum version of Admin Columns Pro plugin is activated. |
| 85 | */ |
| 86 | function ac_is_version_gte( $version ) { |
| 87 | return version_compare( AC()->get_version(), $version, '>=' ); |
| 88 | } |
| 89 | |
| 90 | /** |
| 91 | * Manually set the columns for a list screen |
| 92 | * This overrides the database settings and thus renders the settings screen for this list screen useless |
| 93 | * |
| 94 | * If you like to register a column of your own please have a look at our documentation. |
| 95 | * We also have a free start-kit available, which contains all the necessary files. |
| 96 | * |
| 97 | * Documentation: https://www.admincolumns.com/documentation/developer-docs/creating-new-column-type/ |
| 98 | * Starter-kit: https://github.com/codepress/ac-column-template/ |
| 99 | * |
| 100 | * @since 2.2 |
| 101 | * |
| 102 | * @param string|array $list_screen_key List screen key or keys |
| 103 | * @param array $column_data |
| 104 | */ |
| 105 | function ac_register_columns( $list_screen_keys, $column_data ) { |
| 106 | AC()->api()->load_columndata( $list_screen_keys, $column_data ); |
| 107 | } |
| 108 | |
| 109 | /** |
| 110 | * Deprecated functions |
| 111 | */ |
| 112 | |
| 113 | /** |
| 114 | * Is doing ajax |
| 115 | * |
| 116 | * @since 2.3.4 |
| 117 | */ |
| 118 | function cac_is_doing_ajax() { |
| 119 | _deprecated_function( __FUNCTION__, '3.0' ); |
| 120 | |
| 121 | return AC()->table_screen()->get_list_screen_when_doing_quick_edit() || ( AC()->is_doing_ajax() && isset( $_REQUEST['list_screen'] ) ); |
| 122 | } |
| 123 | |
| 124 | /** |
| 125 | * Is WordPress doing ajax |
| 126 | * |
| 127 | * @since 2.5 |
| 128 | */ |
| 129 | function cac_wp_is_doing_ajax() { |
| 130 | _deprecated_function( __FUNCTION__, '3.0' ); |
| 131 | |
| 132 | return AC()->table_screen()->get_list_screen_when_doing_quick_edit(); |
| 133 | } |
| 134 | |
| 135 | /** |
| 136 | * Whether the current screen is the Admin Columns settings screen |
| 137 | * |
| 138 | * @since 2.4.8 |
| 139 | * |
| 140 | * @param string $slug Specifies a page screen (optional) |
| 141 | * |
| 142 | * @return bool True if the current screen is the settings screen, false otherwise |
| 143 | */ |
| 144 | function cac_is_setting_screen( $slug = '' ) { |
| 145 | _deprecated_function( __FUNCTION__, '3.0', 'AC()->admin()->is_current_page( $slug )' ); |
| 146 | |
| 147 | return AC()->admin()->is_current_page( $slug ); |
| 148 | } |
| 149 | |
| 150 | /** |
| 151 | * Returns true if the installed version of WooCommerce is version X or greater |
| 152 | * |
| 153 | * @since 2.3.4 |
| 154 | * @deprecated 3.0 |
| 155 | * @return boolean true if the installed version of WooCommerce is version X or greater |
| 156 | */ |
| 157 | function cpac_is_wc_version_gte( $version = '1.0' ) { |
| 158 | _deprecated_function( __FUNCTION__, '3.0' ); |
| 159 | |
| 160 | return false; |
| 161 | } |
| 162 | |
| 163 | /** |
| 164 | * @deprecated 3.0 |
| 165 | * @return bool True when Admin Columns Pro plugin is activated. |
| 166 | */ |
| 167 | function cpac_is_pro_active() { |
| 168 | _deprecated_function( __FUNCTION__, '3.0', 'ac_is_pro_active' ); |
| 169 | |
| 170 | return ac_is_pro_active(); |
| 171 | } |
| 172 |