Skip to content

Commit

Permalink
Merge branch '2.x' into 2.x
Browse files Browse the repository at this point in the history
  • Loading branch information
sc0ttkclark authored Mar 18, 2020
2 parents 1bd39f7 + 6560ff4 commit 81b85cd
Show file tree
Hide file tree
Showing 40 changed files with 1,167 additions and 720 deletions.
76 changes: 76 additions & 0 deletions CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
# Contributor Covenant Code of Conduct

## Our Pledge

In the interest of fostering an open and welcoming environment, we as
contributors and maintainers pledge to making participation in our project and
our community a harassment-free experience for everyone, regardless of age, body
size, disability, ethnicity, sex characteristics, gender identity and expression,
level of experience, education, socio-economic status, nationality, personal
appearance, race, religion, or sexual identity and orientation.

## Our Standards

Examples of behavior that contributes to creating a positive environment
include:

* Using welcoming and inclusive language
* Being respectful of differing viewpoints and experiences
* Gracefully accepting constructive criticism
* Focusing on what is best for the community
* Showing empathy towards other community members

Examples of unacceptable behavior by participants include:

* The use of sexualized language or imagery and unwelcome sexual attention or
advances
* Trolling, insulting/derogatory comments, and personal or political attacks
* Public or private harassment
* Publishing others' private information, such as a physical or electronic
address, without explicit permission
* Other conduct which could reasonably be considered inappropriate in a
professional setting

## Our Responsibilities

Project maintainers are responsible for clarifying the standards of acceptable
behavior and are expected to take appropriate and fair corrective action in
response to any instances of unacceptable behavior.

Project maintainers have the right and responsibility to remove, edit, or
reject comments, commits, code, wiki edits, issues, and other contributions
that are not aligned to this Code of Conduct, or to ban temporarily or
permanently any contributor for other behaviors that they deem inappropriate,
threatening, offensive, or harmful.

## Scope

This Code of Conduct applies both within project spaces and in public spaces
when an individual is representing the project or its community. Examples of
representing a project or community include using an official project e-mail
address, posting via an official social media account, or acting as an appointed
representative at an online or offline event. Representation of a project may be
further defined and clarified by project maintainers.

## Enforcement

Instances of abusive, harassing, or otherwise unacceptable behavior may be
reported by contacting the project team at [email protected]. All
complaints will be reviewed and investigated and will result in a response that
is deemed necessary and appropriate to the circumstances. The project team is
obligated to maintain confidentiality with regard to the reporter of an incident.
Further details of specific enforcement policies may be posted separately.

Project maintainers who do not follow or enforce the Code of Conduct in good
faith may face temporary or permanent repercussions as determined by other
members of the project's leadership.

## Attribution

This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html

[homepage]: https://www.contributor-covenant.org

For answers to common questions about this code of conduct, see
https://www.contributor-covenant.org/faq
154 changes: 103 additions & 51 deletions classes/PodsAdmin.php

Large diffs are not rendered by default.

6 changes: 4 additions & 2 deletions classes/PodsI18n.php
Original file line number Diff line number Diff line change
Expand Up @@ -466,8 +466,10 @@ public function get_current_language_data( $args = array() ) {
*/
$lang_data = apply_filters( 'pods_get_current_language', $lang_data, $translator );

self::$current_language = $lang_data['language'];
self::$current_language_data = $lang_data;
if ( $lang_data ) {
self::$current_language = $lang_data['language'];
self::$current_language_data = $lang_data;
}

return $lang_data;

Expand Down
41 changes: 41 additions & 0 deletions classes/PodsInit.php
Original file line number Diff line number Diff line change
Expand Up @@ -1384,6 +1384,8 @@ public function activate() {
*/
public function deactivate() {

delete_option( 'pods_callouts' );

pods_api()->cache_flush_pods();

}
Expand Down Expand Up @@ -1665,6 +1667,9 @@ public function run() {
// Show admin bar links
add_action( 'admin_bar_menu', array( $this, 'admin_bar_links' ), 81 );

// Compatibility with WP 5.4 privacy export.
add_filter( 'wp_privacy_additional_user_profile_data', array( $this, 'filter_wp_privacy_additional_user_profile_data' ), 10, 3 );

// Compatibility for Query Monitor conditionals
add_filter( 'query_monitor_conditionals', array( $this, 'filter_query_monitor_conditionals' ) );

Expand Down Expand Up @@ -1863,6 +1868,42 @@ public function admin_bar_links() {

}

/**
* Add Pod fields to user export.
* Requires WordPress 5.4+
*
* @since 2.7.17
*
* @param array $additional_user_profile_data {
* An array of name-value pairs of additional user data items. Default: the empty array.
*
* @type string $name The user-facing name of an item name-value pair, e.g. 'IP Address'.
* @type string $value The user-facing value of an item data pair, e.g. '50.60.70.0'.
* }
* @param WP_User $user The user whose data is being exported.
* @param array $reserved_names An array of reserved names. Any item in
* `$additional_user_data` that uses one of these
* for it's `name` will not be included in the export.
*
* @return array
*/
public function filter_wp_privacy_additional_user_profile_data( $additional_user_profile_data, $user, $reserved_names ) {
$pod = pods( 'user', $user->ID );

if ( ! $pod->valid() ) {
return $additional_user_profile_data;
}

foreach ( $pod->fields as $name => $field ) {
$additional_user_profile_data[] = array(
'name' => apply_filters( 'pods_form_ui_label_text', $field['label'], $name, '', $field ),
'value' => $pod->display( $name ),
);
}

return $additional_user_profile_data;
}

/**
* Add Pods conditional functions to Query Monitor.
*
Expand Down
41 changes: 37 additions & 4 deletions classes/PodsMigrate.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,21 @@ public function set_data( $data ) {

$this->data = array_merge( $defaults, (array) $data );
}

/**
* Get items.
*
* @since 2.7.17
*
* @return array List of data items.
*/
private function get_items() {

return empty( $this->data['single'] ) ?
$this->data['items'] :
array( $this->data['items'] );

}

/**
* Importing / Parsing / Validating Code
Expand Down Expand Up @@ -570,7 +585,9 @@ public function build_sv( $data = null, $delimiter = null ) {

$head = substr( $head, 0, - 1 );

foreach ( $this->data['items'] as $item ) {
$items = $this->get_items();

foreach ( $items as $item ) {
$line = '';

foreach ( $this->data['columns'] as $column => $label ) {
Expand Down Expand Up @@ -636,10 +653,12 @@ public function build_xml( $data = null ) {
return false;
}

$head = '<' . '?' . 'xml version="1.0" encoding="utf-8" ' . '?' . '>' . "\r\n<items count=\"" . count( $this->data['items'] ) . "\">\r\n";
$items = $this->get_items();

$head = '<' . '?' . 'xml version="1.0" encoding="utf-8" ' . '?' . '>' . "\r\n<items count=\"" . count( $items ) . "\">\r\n";
$lines = '';

foreach ( $this->data['items'] as $item ) {
foreach ( $items as $item ) {
$line = "\t<item>\r\n";

foreach ( $this->data['columns'] as $column => $label ) {
Expand Down Expand Up @@ -1258,10 +1277,24 @@ public static function export_data_to_file( $file, $data, $single = false ) {
}

$migrate_data = array(
'items' => array( $data ),
'items' => $data,
'single' => $single,
);

// Try to guess the column labels based on the supplied data.
$first_item = null;

if ( $single ) {
$first_item = $data;
} elseif ( is_array( $data ) ) {
$first_item = reset( $data );
}

if ( is_array( $first_item ) ) {
$fields = array_keys( $first_item );
$migrate_data['columns'] = array_combine( $fields, $fields );
}

$migrate = new self( $format, null, $migrate_data );

// Handle processing the data into the format needed.
Expand Down
Loading

0 comments on commit 81b85cd

Please sign in to comment.