Skip to content

Commit

Permalink
Merge pull request #1308 from insideout10/release/3.29.0
Browse files Browse the repository at this point in the history
Release/3.29.0
  • Loading branch information
akshayraje authored Mar 4, 2021
2 parents 789618b + d161bf8 commit 8a2a4a3
Show file tree
Hide file tree
Showing 109 changed files with 7,667 additions and 5,223 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "wordlift-plugin",
"description": "WordLift brings the power of Artificial Intelligence to organize content. Attract new readers and get their true attention with top notch semantic seo.",
"private": true,
"version": "3.28.1",
"version": "3.29.0",
"author": "WordLift",
"homepage": "https://wordift.io/",
"license": "GPL-3.0",
Expand Down
2 changes: 1 addition & 1 deletion src-js/webpack/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "wordlift-plugin",
"version": "3.28.1",
"version": "3.29.0",
"description": "WordLift Plugin application for the web site public front-end.",
"main": "index.js",
"repository": "https://github.com/insideout10/wordlift-plugin",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
import { connect } from "react-redux";

import { close } from "./actions";
import Wrapper from "./Wrapper";

const mapStateToProps = state => ({ open: state.open });

const mapDispatchToProps = dispatch => ({
onBlur: () => dispatch(close())
});

export default connect(mapStateToProps, mapDispatchToProps)(Wrapper);
export default connect(mapStateToProps)(Wrapper);
6 changes: 4 additions & 2 deletions src-js/webpack/src/Edit/components/EntityTile/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,9 @@ class EntityTile extends React.Component {
? applyFilters("wl_network_icon_url", defaultNetworkIconURL)
: defaultNetworkIconURL;

this.iconURL = this.props.entity.local
let isLocalEntity = this.props.entity.local || this.props.entity.id.startsWith(window.location.origin);

this.iconURL = isLocalEntity
? defaultLocalIconURL
: this.props.entity.id.match(/https?:\/\/(?:\w+\.)?(dbpedia|wikidata)\.org/)
? this.cloudIconURL
Expand All @@ -191,7 +193,7 @@ class EntityTile extends React.Component {
{this.props.entity.label}
<MainType entity={this.props.entity}>{this.props.entity.mainType}</MainType>
</Label>
<IconImg src={this.iconURL} />
{this.iconURL && <IconImg src={this.iconURL} />}
</Main>
<Drawer open={this.state.open}>
<Switch onClick={this.onSwitchClick} selected={this.props.entity.link}>
Expand Down
37 changes: 5 additions & 32 deletions src-js/webpack/src/Edit/stores/sagas.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import {
EDITOR_SELECTION_CHANGED,
SET_CURRENT_ENTITY,
TOGGLE_ENTITY,
TOGGLE_LINK,
TOGGLE_LINK
} from "../constants/ActionTypes";
import EditPostWidgetController from "../angular/EditPostWidgetController";
import { getEntity } from "./selectors";
Expand All @@ -27,9 +27,8 @@ import {
addEntityRequest,
addEntitySuccess,
createEntityRequest,
createEntitySuccess,
createEntitySuccess
} from "../components/AddEntity/actions";
import { Button, createPopover } from "@wordlift/design";
import React from "react";

/**
Expand All @@ -50,7 +49,7 @@ function* toggleLink({ entity }) {
yield put(
toggleLinkSuccess({
id: entity.id,
link: LinkService.getLink(entity.occurrences),
link: LinkService.getLink(entity.occurrences)
})
);
}
Expand Down Expand Up @@ -88,7 +87,7 @@ function* createEntity({ payload }) {
yield put(createEntitySuccess());
}

const getMainType = (types) => {
const getMainType = types => {
for (let i = 0; i < window._wlEntityTypes.length; i++) {
const type = window._wlEntityTypes[i];

Expand Down Expand Up @@ -131,34 +130,8 @@ function* handleEditorSelectionChanged({ payload }) {
top: iframeRect.top + editorRect.top + window.scrollY,
right: iframeRect.left + editorRect.right + window.scrollX,
bottom: iframeRect.top + editorRect.bottom + window.scrollY,
left: iframeRect.left + editorRect.left + window.scrollX,
left: iframeRect.left + editorRect.left + window.scrollX
};

// const container = document.createElement("span");
// container.style.position = "absolute";
// container.style.top = "0";
// container.style.left = "0";
//
// const span = document.createElement("span");
// span.style.width = rect.right - rect.left + "px";
// span.style.height = rect.bottom - rect.top + "px";
// span.style.top = rect.top + "px";
// span.style.left = rect.left + "px";
// span.style.background = "transparent";
// span.style.border = "1px solid red";
// span.style.position = "absolute";
//
// container.appendChild(span);
// document.body.appendChild(container);

// Finally create the popover.
// popover = yield call(
// createPopover,
// <div>
// <Button>Hello WordPress!</Button>
// </div>,
// { ...rect, positions: ["right", "left", "bottom", "top"] }
// );
}

/**
Expand Down
10 changes: 7 additions & 3 deletions src-js/webpack/src/block-editor/stores/sagas.js
Original file line number Diff line number Diff line change
Expand Up @@ -225,9 +225,13 @@ function* handleAddEntityRequest({ payload }) {
payload.id ||
(yield call(createEntity, {
title: payload.label,
status: "draft",
description: payload.description,
excerpt: ""
// Set entity type to the created entity.
wlEntityMainType: [payload.category],
// Inherit the status from the edited post.
status: wp.data.select('core/editor').getEditedPostAttribute('status'),
// wp rest api uses content as the alias for description
content: payload.description,
excerpt: "",
}))["wl:entity_url"];

const entityToAdd = {
Expand Down
17 changes: 16 additions & 1 deletion src-js/webpack/src/mappings/api/edit-mapping-api.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,19 @@ function getTermsFromAPI(taxonomy) {
}).then(response => response.json().then(data => data));
}

export default { getMappingItemByMappingId, saveMappingItem, getTermsFromAPI };

function getTaxonomyTermsFromAPI(taxonomy) {
const postObject = {
taxonomy: taxonomy
};
return fetch(rest_url + "/get_taxonomy_terms", {
method: "POST",
headers: {
"content-type": "application/json",
"X-WP-Nonce": wl_edit_mapping_rest_nonce
},
body: JSON.stringify(postObject)
}).then(response => response.json().then(data => data));
}

export default { getMappingItemByMappingId, saveMappingItem, getTermsFromAPI, getTaxonomyTermsFromAPI };
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ class RuleComponent extends React.Component {
this.handleSelectFieldChange(e, "ruleFieldTwoValue");
}}
className="wl-field-two-select wl-form-select"
inputDataIsOptionGroup={this.props.ruleProps.ruleFieldOneValue === 'post_taxonomy' ? true : false}
/>
</WlColumn>
<AddRuleButton {...this.props} />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,10 +97,12 @@ export const RuleGroupReducer = createReducer(null, {
[MAPPING_TERMS_CHANGED]: (state, action) => {
const taxonomy = action.payload.taxonomy;
const terms = action.payload.terms;

// Check if there is no term items for the taxonomy, to prevent duplication.
if (0 === state.ruleFieldTwoOptions.filter(e => e.taxonomy === taxonomy).length) {
if (0 === state.ruleFieldTwoOptions.filter(e => e.taxonomy === taxonomy).length || 'post_taxonomy' === taxonomy) {
state.ruleFieldTwoOptions = state.ruleFieldTwoOptions.concat(terms);
}

},
[EDIT_MAPPING_TERMS_FETCHED_FOR_TAXONOMY]: (state, action) => {
const taxonomy = action.payload.taxonomy;
Expand Down
25 changes: 18 additions & 7 deletions src-js/webpack/src/mappings/store/edit-mapping-sagas.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,25 @@ function* getTermsForSelectedTaxonomy(action) {
// It means the terms are already present for the taxonomy, not needed to fetch it again from API.
return;
}
const response = yield call(EDIT_MAPPING_API.getTermsFromAPI, ruleFieldOneSelectedValue);
const terms = response.map(e => {
return {
label: e.name,
value: e.slug,
parentValue: e.taxonomy
};

const callAPILink = ruleFieldOneSelectedValue === 'post_taxonomy' ? EDIT_MAPPING_API.getTaxonomyTermsFromAPI : EDIT_MAPPING_API.getTermsFromAPI;
const response = yield call(callAPILink, ruleFieldOneSelectedValue);
const terms = response.map(e => {
if (e.hasOwnProperty('group_name')) {
return {
group_name: e.group_name,
group_options: e.group_options,
parentValue: e.parentValue
}
} else {
return {
label: e.name,
value: e.slug,
parentValue: e.taxonomy
};
}
});

MAPPING_TERMS_CHANGED_ACTION.payload = {
taxonomy: ruleFieldOneSelectedValue,
terms: terms
Expand Down
26 changes: 9 additions & 17 deletions src/admin/WL_Metabox/class-wl-metabox-field-sameas.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,24 +92,21 @@ protected function get_add_button_html( $count ) {
$placeholder = esc_attr_x( 'Type here the URL of an equivalent entity from another dataset.', 'sameAs metabox input', 'wordlift' );

return
"<label for='$this->meta_name'>"
. esc_html__( 'If you already know the URL of the entity that you would like to link, add it in the field below.', 'wordlift' )
. '</label>'
. '<div class="wl-input-wrapper">'
. "<input type='text' id='$this->meta_name' name='wl_metaboxes[$this->meta_name][]' placeholder='$placeholder' style='width:88%' />"
. '<button class="button wl-remove-input wl-button" type="button">Remove</button>'
. '</div>'
. parent::get_add_button_html( $count );
'<button class="wl-add-input wl-add-input--link">'.esc_html__( 'Click here to manually add URLs', 'wordlift' ).'</button>'
.'<div style="display: none;"><div class="wl-input-wrapper">'
."<input type='text' id='$this->meta_name' name='wl_metaboxes[$this->meta_name][]' placeholder='$placeholder' />"
.'<button class="wl-remove-input wl-remove-input--sameas"></button>'
.'</div></div>'
. '<fieldset id="wl-input-container">'.$this->get_stored_values_html( $count ).'</fieldset>'
.parent::get_add_custom_button_html( $count, 'Add Another URL', 'hide' );
}

/**
* @inheritdoc
*/
protected function get_stored_values_html( &$count ) {

return '<p>'
. parent::get_stored_values_html( $count )
. '</p>';
return parent::get_stored_values_html( $count );
}

/**
Expand All @@ -132,8 +129,6 @@ public function html() {
// If cardinality allows it, print button to add new values.
$html .= $this->get_add_button_html( $count );

$html .= $this->get_stored_values_html( $count );

// Close the HTML wrapper.
$html .= $this->html_wrapper_close();

Expand All @@ -153,12 +148,9 @@ public function html_input( $value ) {
id="<?php echo $this->meta_name ?>"
name="wl_metaboxes[<?php echo $this->meta_name ?>][]"
value="<?php echo $value ?>"
style="width:88%"
/>

<button class="button wl-remove-input wl-button" type="button">
<?php esc_html_e( 'Remove', 'wordlift' ); ?>
</button>
<button class="wl-remove-input wl-remove-input--sameas"></button>
</div>
<?php

Expand Down
25 changes: 24 additions & 1 deletion src/admin/WL_Metabox/class-wl-metabox-field.php
Original file line number Diff line number Diff line change
Expand Up @@ -423,6 +423,29 @@ protected function get_add_button_html( $count ) {
return '';
}

/**
* Get the add custom button html.
*
* This function is protected, allowing extending class to further customize
* the add button html code.
*
* @since 3.15.0
*
* @param int $count The current number of values.
*
* @return string The add button html code.
*/
protected function get_add_custom_button_html( $count, $label, $class = '' ) {

// If cardinality allows it, print button to add new values.
if ( $count < $this->cardinality ) {
return '<button class="button wl-add-input wl-button wl-add-input--sameas '.$class.'" type="button">' . esc_html__( $label ) . '</button>';
}

// Return an empty string.
return '';
}

/**
* Return a single <input> tag for the Field.
*
Expand Down Expand Up @@ -457,7 +480,7 @@ public function html_input( $value ) {
*/
public function html_wrapper_close() {

return '</div><hr>';
return '</div>';
}

}
Loading

0 comments on commit 8a2a4a3

Please sign in to comment.