Skip to content

Commit 167a482

Browse files
authored
Merge pull request #245 from codepress/release/3.4.2
Release/3.4.2
2 parents 13d6d2a + 787fed2 commit 167a482

File tree

61 files changed

+178
-32336
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+178
-32336
lines changed

assets/js/admin-page-columns.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

assets/js/admin-page-columns.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

classes/Admin/Page/Columns.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,8 +121,12 @@ public function admin_scripts() {
121121
$params = $ajax_handler->get_params();
122122

123123
$params['i18n'] = array(
124-
'clone' => __( '%s column is already present and can not be duplicated.', 'codepress-admin-columns' ),
125-
'error' => __( 'Invalid response.', 'codepress-admin-columns' ),
124+
'clone' => __( '%s column is already present and can not be duplicated.', 'codepress-admin-columns' ),
125+
'error' => __( 'Invalid response.', 'codepress-admin-columns' ),
126+
'errors' => array(
127+
'save_settings' => __( 'There was an error during saving the column settings.', 'codepress-admin-columns' ),
128+
'loading_column' => __( 'The column could not be loaded because of an unknown error', 'codepress-admin-columns' ),
129+
),
126130
);
127131

128132
wp_localize_script( 'ac-admin-page-columns', 'AC', $params );

classes/AdminColumns.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,13 +73,13 @@ private function __construct() {
7373
}
7474

7575
$this->register_admin();
76+
$this->localize();
7677

7778
add_action( 'init', array( $this, 'init_capabilities' ) );
7879
add_action( 'init', array( $this, 'install' ) );
7980
add_action( 'init', array( $this, 'notice_checks' ) );
8081

8182
add_filter( 'plugin_action_links', array( $this, 'add_settings_link' ), 1, 2 );
82-
add_action( 'plugins_loaded', array( $this, 'localize' ) );
8383

8484
add_action( 'ac/screen', array( $this, 'init_table_on_screen' ) );
8585
add_action( 'ac/screen/quick_edit', array( $this, 'init_table_on_quick_edit' ) );
@@ -331,7 +331,9 @@ public function get_post_types() {
331331
* Load text-domain
332332
*/
333333
public function localize() {
334-
load_plugin_textdomain( 'codepress-admin-columns', false, $this->get_dir() . '/languages/' );
334+
$path = pathinfo( $this->get_dir() );
335+
336+
load_plugin_textdomain( 'codepress-admin-columns', false, $path['basename'] . '/languages/' );
335337
}
336338

337339
/**

classes/Column/User/Registered.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,13 @@ public function get_value( $user_id ) {
2020
}
2121

2222
public function get_raw_value( $user_id ) {
23-
return get_userdata( $user_id )->user_registered;
23+
$user_data = get_userdata( $user_id );
24+
25+
if ( ! $user_data ) {
26+
return null;
27+
}
28+
29+
return $user_data->user_registered;
2430
}
2531

2632
public function register_settings() {

classes/Meta/Query.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,8 @@ private function get_where_clause( $field, $operator = null, $value = null, $boo
199199
$nested = array();
200200

201201
if ( is_array( $field ) ) {
202-
for ( $i = 0; $i < count( $field ); $i++ ) {
202+
$count = count( $field );
203+
for ( $i = 0; $i < $count; $i++ ) {
203204
$nested[] = array_pop( $this->where );
204205
}
205206
}

classes/Settings/Column/CustomFieldType.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ public function get_dependent_settings() {
3131
case 'image' :
3232
case 'library_id' :
3333
$settings[] = new Image( $this->column );
34+
$settings[] = new MediaLink( $this->column );
3435

3536
break;
3637
case 'excerpt' :
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
<?php
2+
3+
namespace AC\Settings\Column;
4+
5+
use AC;
6+
use AC\Settings;
7+
use AC\View;
8+
9+
class MediaLink extends Settings\Column
10+
implements Settings\FormatValue {
11+
12+
/**
13+
* @var string
14+
*/
15+
protected $media_link_to;
16+
17+
protected function define_options() {
18+
return array(
19+
'media_link_to' => '',
20+
);
21+
}
22+
23+
public function format( $value, $original_value ) {
24+
$id = $original_value;
25+
26+
switch ( $this->get_media_link_to() ) {
27+
case 'view' :
28+
case 'download' :
29+
$link = wp_get_attachment_url( $id );
30+
31+
break;
32+
default :
33+
$link = false;
34+
}
35+
36+
if ( $link ) {
37+
$attributes = array();
38+
39+
if ( 'download' === $this->get_media_link_to() ) {
40+
$attributes['download'] = '';
41+
}
42+
43+
$value = ac_helper()->html->link( $link, $value, $attributes );
44+
}
45+
46+
return $value;
47+
}
48+
49+
public function create_view() {
50+
$select = $this->create_element( 'select' )->set_options( $this->get_link_options() );
51+
52+
$view = new View( array(
53+
'label' => __( 'Link To', 'codepress-admin-columns' ),
54+
'setting' => $select,
55+
) );
56+
57+
return $view;
58+
}
59+
60+
protected function get_link_options() {
61+
return array(
62+
'' => __( 'None' ),
63+
'view' => __( 'View', 'codepress-admin-columns' ),
64+
'download' => __( 'Download', 'codepress-admin-columns' ),
65+
);
66+
}
67+
68+
/**
69+
* @return string
70+
*/
71+
public function get_media_link_to() {
72+
return $this->media_link_to;
73+
}
74+
75+
/**
76+
* @param string $media_link_to
77+
*
78+
* @return bool
79+
*/
80+
public function set_media_link_to( $media_link_to ) {
81+
$this->media_link_to = $media_link_to;
82+
83+
return true;
84+
}
85+
86+
}

classes/Settings/Column/Meta.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ private function group_keys( $keys ) {
195195

196196
// Place the hidden group at the end
197197
if ( isset( $grouped['_'] ) ) {
198-
array_push( $grouped, $grouped['_'] );
198+
$grouped[] = $grouped['_'];
199199

200200
unset( $grouped['_'] );
201201
}

classes/Storage/Timestamp.php

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,17 +26,11 @@ public function __construct( KeyValuePair $storage ) {
2626
* @return bool
2727
*/
2828
public function is_expired( $time = null ) {
29-
$value = $this->get();
30-
31-
if ( false === $value ) {
32-
return true;
33-
}
34-
3529
if ( null === $time ) {
3630
$time = time();
3731
}
3832

39-
return $time > $value;
33+
return $time > (int) $this->get();
4034
}
4135

4236
/**

0 commit comments

Comments
 (0)