microsoft-start-v1.2 (#2)
This commit is contained in:
Родитель
cbe636facd
Коммит
be37409f6f
|
@ -61,16 +61,6 @@ class MSNOptions extends Options
|
|||
return static::Option(func_get_args(), true);
|
||||
}
|
||||
|
||||
public static function Language()
|
||||
{
|
||||
return static::Option(func_get_args(), strtoupper(substr(get_locale(), 0, 2)));
|
||||
}
|
||||
|
||||
public static function Market()
|
||||
{
|
||||
return static::Option(func_get_args(), strtolower(str_replace("_", "-", get_locale())));
|
||||
}
|
||||
|
||||
public static function Category()
|
||||
{
|
||||
return static::Option(func_get_args(), "uncatagorised");
|
||||
|
|
|
@ -8,7 +8,6 @@ import { Container } from 'microsoft_core/components'
|
|||
import { Content } from './content/content.jsx';
|
||||
import { MicrosoftLogo } from 'microsoft_core/icons.jsx'
|
||||
import { Monetization } from "./monetization/monetization.jsx"
|
||||
import { Payment } from "./payment/payment.jsx"
|
||||
import React from 'react';
|
||||
import ReactDOM from 'react-dom';
|
||||
import { Settings } from "./settings/settings.jsx"
|
||||
|
@ -39,10 +38,12 @@ function AdminDashboard() {
|
|||
</NavLink >
|
||||
</li>
|
||||
<li className="mr-6 m-0">
|
||||
<NavLink to="/payments" className="text-black no-underline focus:shadow-none" activeClassName="border-b-2 border-0 border-solid border-microsoft font-bold">{__('Payments')}</NavLink>
|
||||
</li>
|
||||
<li className="mr-6 m-0">
|
||||
<NavLink to="/monetization" className="text-black no-underline focus:shadow-none" activeClassName="border-b-2 border-0 border-solid border-microsoft font-bold">{__('Monetization')}</NavLink>
|
||||
{msn_dashboard_render_status.profile && (
|
||||
<NavLink to="/monetization" className="text-black no-underline focus:shadow-none" activeClassName="border-b-2 border-0 border-solid border-microsoft font-bold">{__('Monetization')}</NavLink>
|
||||
)}
|
||||
{!msn_dashboard_render_status.profile && (
|
||||
<span className="text-gray-400">{__('Monetization')}</span>
|
||||
)}
|
||||
</li>
|
||||
<li className="mr-6 m-0">
|
||||
<NavLink to="/settings" className="text-black no-underline focus:shadow-none" activeClassName="border-b-2 border-0 border-solid border-microsoft font-bold">{__('Settings')}</NavLink>
|
||||
|
@ -67,12 +68,6 @@ function AdminDashboard() {
|
|||
<Content />
|
||||
</Container>
|
||||
</Route>
|
||||
<Route path="/payments">
|
||||
<Container>
|
||||
<h1 className="mt-5 mb-2.5 text-xl">{__("Payments")}</h1>
|
||||
<Payment />
|
||||
</Container>
|
||||
</Route>
|
||||
<Route path="/monetization">
|
||||
<Container>
|
||||
<h1 className="mt-5 mb-2.5 text-xl">{__("Monetization")}</h1>
|
||||
|
|
|
@ -3,6 +3,10 @@
|
|||
import React, { useEffect, useState } from 'react';
|
||||
|
||||
export function Monetization() {
|
||||
if(!msn_dashboard_render_status.profile) {
|
||||
return <span>Error loading account details</span>;
|
||||
}
|
||||
|
||||
var [token, setToken] = useState(null);
|
||||
const accountId = msn_dashboard_render_status.profile.accountId;
|
||||
const partnerId = msn_dashboard_render_status.profile.partnerId;
|
||||
|
|
|
@ -1,35 +0,0 @@
|
|||
// © Microsoft Corporation. All rights reserved.
|
||||
|
||||
import { DashboardWidget } from 'microsoft_core/components'
|
||||
import { __ } from "@wordpress/i18n";
|
||||
|
||||
export function Payment() {
|
||||
return (
|
||||
<DashboardWidget className = 'p-6 m-0 mb-0'>
|
||||
<p className="text-gray-400 m-0 p-0">
|
||||
{__("Microsoft shares revenue with content creators if they qualify. Visit these Microsoft sites for more information ")}
|
||||
|
||||
</p>
|
||||
<ul className = "h-36 p-0 mt-6">
|
||||
<li className="flex border-b border-gray-300 border-solid border-0 py-2 m-0 pb-0">
|
||||
<div className="flex-grow pb-4">
|
||||
<p className="font-bold mt-0 mb-1">{__("Payment Central ")}</p>
|
||||
{__("Manage your account and profile to receive payments ")}
|
||||
</div>
|
||||
<a href="https://paymentcentral.microsoft.com/" target="_blank" className="whitespace-nowrap no-underline">
|
||||
{__("Go to site ")}
|
||||
</a>
|
||||
</li>
|
||||
<li className="flex py-2 pt-0">
|
||||
<div className="flex-grow pt-4">
|
||||
<p className="font-bold mt-0 mb-1">{__("Royalty Statements")}</p>
|
||||
{__("If you have royalty statements from Microsoft, they will appear here ")}
|
||||
</div>
|
||||
<a href="https://royalty.microsoft.com/" target="_blank" className="whitespace-nowrap no-underline self-end">
|
||||
{__("Check Statement")}
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
</DashboardWidget>
|
||||
);
|
||||
}
|
|
@ -23,7 +23,7 @@ export function Settings() {
|
|||
</NavLink>
|
||||
)}
|
||||
|
||||
{!msn_dashboard_render_status.enabled && (<span className="text-gray-300">{__('Account Profile')}</span>)}
|
||||
{!msn_dashboard_render_status.enabled && (<span className="text-gray-400">{__('Account Profile')}</span>)}
|
||||
|
||||
</li>
|
||||
<li className="px-3.5 m-0">
|
||||
|
@ -32,7 +32,7 @@ export function Settings() {
|
|||
{__('Content Settings')}
|
||||
</NavLink>
|
||||
)}
|
||||
{!msn_dashboard_render_status.enabled && (<span className="text-gray-300">{__('Content Settings')}</span>)}
|
||||
{!msn_dashboard_render_status.enabled && (<span className="text-gray-400">{__('Content Settings')}</span>)}
|
||||
</li>
|
||||
</ul>
|
||||
</nav>
|
||||
|
|
|
@ -2,20 +2,23 @@
|
|||
// © Microsoft Corporation. All rights reserved.
|
||||
|
||||
/**
|
||||
* Plugin Name: Microsoft News
|
||||
* Description: Publish articles to Microsoft news
|
||||
* Version: #{PLUGIN_VERSION}#
|
||||
* Plugin Name: Microsoft Start
|
||||
* Plugin URI: https://www.msn.com/
|
||||
* Description: Microsoft Start WordPress plugin to help WordPress content creators to share content to Microsoft Start News feed.
|
||||
* Version: 1.2
|
||||
* Requires at least: 5.4
|
||||
* Requires PHP: 7.3
|
||||
* Author: Microsoft
|
||||
* Author URI: http://www.microsoft.com
|
||||
* Requires PHP: 7.3
|
||||
* Author: Microsoft
|
||||
* Author URI: https://www.microsoft.com/
|
||||
* License: GPL v2 or later
|
||||
* License URI: https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
|
||||
namespace microsoft_news;
|
||||
|
||||
//define('WP_DEBUG', true);
|
||||
//define('WP_DEBUG_DISPLAY', true);
|
||||
// define( 'WP_DEBUG_LOG', '/tmp/wp-errors.log' );
|
||||
//define( 'WP_DEBUG_LOG', '/tmp/wp-errors.log' );
|
||||
|
||||
require __DIR__ . '/vendor/autoload.php';
|
||||
|
||||
|
|
|
@ -5,12 +5,12 @@ import { __ } from "@wordpress/i18n";
|
|||
import { withSelect } from '@wordpress/data';
|
||||
|
||||
const PostPublishPanel = ({meta}) => {
|
||||
const { msn_id, MSN_Markets } = meta;
|
||||
const { msn_id } = meta;
|
||||
|
||||
if (msn_id) {
|
||||
return (
|
||||
<PluginPostPublishPanel>
|
||||
<a href={`https://www.msn.com/${MSN_Markets}/creator/management/content/article`} target="_blank">{__("View Post in Microsoft")}</a>
|
||||
<a href={`https://www.msn.com/en-us/creator/management/content/article`} target="_blank">{__("View Post in Microsoft")}</a>
|
||||
</PluginPostPublishPanel>
|
||||
)
|
||||
}
|
||||
|
|
|
@ -9,21 +9,14 @@ import { NewsSelector } from './selector.jsx';
|
|||
import { __ } from "@wordpress/i18n";
|
||||
import { categories } from "../categories.jsx"
|
||||
import classNames from 'classnames';
|
||||
import { languages } from "../msnLanguages.jsx"
|
||||
|
||||
const NewsPanelBody = ({ meta, visibility, editPost, ...props }) => {
|
||||
const { MSN_Location, MSN_Categories, MSN_Publish_Option, MSN_Language, MSN_Markets, msn_id } = meta;
|
||||
const { MSN_Location, MSN_Categories, MSN_Publish_Option, msn_id } = meta;
|
||||
|
||||
const setCategory = (value) => editPost({ meta: { MSN_Categories: value } });
|
||||
const setOption = (value) => editPost({ meta: { MSN_Publish_Option: value } });
|
||||
const setLanguage = (value) => editPost({ meta: { MSN_Language: value } });
|
||||
const setMarket = (value) => editPost({ meta: { MSN_Markets: value } });
|
||||
const setLocation = (value) => editPost({ meta: { MSN_Location: value } });
|
||||
let categoryList = Object.entries(categories).map(pair => <option value={pair[1]}>{pair[0]}</option>);
|
||||
let languageDictionary = languages.reduce((languages, country) => {
|
||||
languages[country.value] = country;
|
||||
return languages
|
||||
}, {});
|
||||
|
||||
let parsedLocationData = {};
|
||||
if(MSN_Location) {
|
||||
|
@ -108,26 +101,11 @@ const NewsPanelBody = ({ meta, visibility, editPost, ...props }) => {
|
|||
</PanelRow>
|
||||
</div>
|
||||
<div className="pb-5">
|
||||
<PanelRow>
|
||||
<NewsSelector name='languages' title={__('Language')} value={MSN_Language} onChange={(value) => {
|
||||
setLanguage(value);
|
||||
setMarket(languageDictionary[value].markets[0].value);
|
||||
}}>
|
||||
{languages.map(language => <option value={language.value}>{__(language.name)}</option>)}
|
||||
</NewsSelector>
|
||||
</PanelRow>
|
||||
{__(MSN_Language) && (
|
||||
<PanelRow>
|
||||
<NewsSelector name='markets' title={__('Market')} onChange={setMarket} value={MSN_Markets}>
|
||||
{(languageDictionary[MSN_Language].markets || []).map(market => <option value={market.value}>{__(market.name)}</option>)}
|
||||
</NewsSelector>
|
||||
</PanelRow>
|
||||
)}
|
||||
{__(MSN_Location) && (
|
||||
<PanelRow>
|
||||
<div className="w-full">
|
||||
<label className="block mb-1">{'Location'}</label>
|
||||
<iframe id="locationSelector" src={`https://int.msn.com/en-us/creator/embed/locationSelector?longitude=${geo.longitude}$latitude=${geo.latitude}$locality=${address.addressLocality}$region=${address.addressRegion}$subRegion=${address.addressSubregion}&country=${address.addressCountry}`}></iframe>
|
||||
<iframe id="locationSelector" src={`https://int.msn.com/en-us/creator/embed/locationSelector?locality=${address.addressLocality}®ion=${address.addressRegion}&subRegion=${address.addressSubregion}&country=${address.addressCountry}&latitude=${geo.latitude}&longitude=${geo.longitude}`}></iframe>
|
||||
<input id="locationSelectorInput" onClick={(e) => setLocation(e.target.value)} value={MSN_Location} type="hidden"/>
|
||||
</div>
|
||||
</PanelRow>
|
||||
|
@ -146,7 +124,7 @@ const NewsPanelBody = ({ meta, visibility, editPost, ...props }) => {
|
|||
|
||||
{msn_id && (
|
||||
<PanelRow>
|
||||
<a href={`https://www.msn.com/${MSN_Markets}/creator/management/content/article`} target="_blank">{__("View Post in Microsoft")}</a>
|
||||
<a href={`https://www.msn.com/en-us/creator/management/content/article`} target="_blank">{__("View Post in Microsoft")}</a>
|
||||
</PanelRow>
|
||||
)}
|
||||
</>
|
||||
|
|
|
@ -65,19 +65,6 @@ class PostEditor
|
|||
'single' => true,
|
||||
'auth_callback' => true
|
||||
));
|
||||
|
||||
register_meta( 'post', 'MSN_Language', array(
|
||||
'show_in_rest' => true,
|
||||
'type' => 'string',
|
||||
'single' => true,
|
||||
'auth_callback' => true
|
||||
));
|
||||
register_meta( 'post', 'MSN_Markets', array(
|
||||
'show_in_rest' => true,
|
||||
'type' => 'string',
|
||||
'single' => true,
|
||||
'auth_callback' => true
|
||||
));
|
||||
register_meta('post', 'msn_id', array(
|
||||
'show_in_rest' => true,
|
||||
'type' => 'string',
|
||||
|
|
|
@ -101,8 +101,6 @@ class Posts
|
|||
|
||||
if ($post_before == null) {
|
||||
update_post_meta($post_ID, "MSN_Publish_Option", MSNOptions::Enabled());
|
||||
update_post_meta($post_ID, "MSN_Language", MSNOptions::Language());
|
||||
update_post_meta($post_ID, "MSN_Markets", MSNOptions::Market());
|
||||
update_post_meta($post_ID, "MSN_Categories", MSNOptions::Category());
|
||||
update_post_meta($post_ID, "MSN_Location", MSNOptions::Location());
|
||||
}
|
||||
|
@ -152,7 +150,6 @@ class Posts
|
|||
"tags" => array_map(function ($post_tag) {
|
||||
return $post_tag->name;
|
||||
}, wp_get_post_tags($post->ID)),
|
||||
"locale" => get_post_meta($post->ID, 'MSN_Markets', true),
|
||||
"location" => json_decode(get_post_meta($post->ID, 'MSN_Location', true))
|
||||
];
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче