楽天の設定画面・グッズメモ アフィリエイト

グッズメモ アフィリエイト・WordPressプラグインのソースコード記事の目次WordPress

CommonRESTParagraph.php

namespace goodsmemo\option\rakuten;

use goodsmemo\option\paragraph\AbstractParagraph;
use goodsmemo\option\paragraph\AbstractTextParagraph;
use goodsmemo\option\PageInfo;
use goodsmemo\option\SectionInfo;
use goodsmemo\option\field\TextField;

require_once GOODS_MEMO_DIR . "option/paragraph/AbstractParagraph.php";
require_once GOODS_MEMO_DIR . "option/paragraph/AbstractTextParagraph.php";
require_once GOODS_MEMO_DIR . "option/PageInfo.php";
require_once GOODS_MEMO_DIR . "option/SectionInfo.php";
require_once GOODS_MEMO_DIR . "option/field/TextField.php";

/**
 * Description of CommonRESTParagraph
 *
 * @author Goods Memo
 */
class CommonRESTParagraph extends AbstractParagraph {

    use AbstractTextParagraph;

    public function initParagraph(PageInfo $pageInfo, SectionInfo $sectionInfo, $fieldInfoArray) {

	parent::setOptionGroup($pageInfo->getOptionGroup());
	parent::setSectionTitle($sectionInfo->getSectionTitle());
	parent::setFieldInfoArray($fieldInfoArray);

	$applicationID = new TextField($pageInfo->getOptionNameOfDatabase(), $fieldInfoArray[0]);
	parent::addField($pageInfo, $sectionInfo, $applicationID);

	$affiliateID = new TextField($pageInfo->getOptionNameOfDatabase(), $fieldInfoArray[1]);
	parent::addField($pageInfo, $sectionInfo, $affiliateID);
    }

    public function sanitizeParagraphValue($inputedValueMap, &$sanitizedValueMap) {
	//sanitizedValueMap:変更するため、配列の参照渡しとする。

	$this->validateExistence($inputedValueMap);
	parent::sanitizeParagraphValue($inputedValueMap, $sanitizedValueMap);
    }

}

CommonRESTParagraphUtils.php

namespace goodsmemo\option\rakuten;

use goodsmemo\option\field\FieldInfo;
use goodsmemo\option\rakuten\RakutenSettingSection;

require_once GOODS_MEMO_DIR . "option/field/FieldInfo.php";
require_once GOODS_MEMO_DIR . "option/rakuten/RakutenSettingSection.php";

/**
 * Description of CommonRESTParagraphUtils
 *
 * @author Goods Memo
 */
class CommonRESTParagraphUtils {

    const APPLICATION_ID_ID = RakutenSettingSection::ID_PREFIX . "_application_id_id";
    const AFFILIATE_ID_ID = RakutenSettingSection::ID_PREFIX . "_affiliate_id_id";

    public static function makeFieldInfoArray() {

	$fieldInfoArray = array();

	$applicationIDFieldInfo = new FieldInfo();
	$applicationIDFieldInfo->setFieldID(CommonRESTParagraphUtils::APPLICATION_ID_ID);
	$applicationIDFieldInfo->setFieldLabel('楽天アプリID/デベロッパーID');
	$applicationIDFieldInfo->setDefaultFieldValue("");
	array_push($fieldInfoArray, $applicationIDFieldInfo);

	$affiliateIDFieldInfo = new FieldInfo();
	$affiliateIDFieldInfo->setFieldID(CommonRESTParagraphUtils::AFFILIATE_ID_ID);
	$affiliateIDFieldInfo->setFieldLabel('楽天アフィリエイトID');
	$affiliateIDFieldInfo->setDefaultFieldValue("");
	array_push($fieldInfoArray, $affiliateIDFieldInfo);

	return $fieldInfoArray;
    }

}

ImageParagraphUtils.php

namespace goodsmemo\option\rakuten;

/**
 * Description of ImageFieldUtils
 *
 * @author Goods Memo
 */
class ImageParagraphUtils {

    const DEFAULT_MEDIUM_IMAGE_WIDTH = 128;
    const DEFAULT_MEDIUM_IMAGE_HEIGHT = 128;

}

ItemHTMLParagraphUtils.php

namespace goodsmemo\option\rakuten;

use goodsmemo\option\field\FieldInfo;
use goodsmemo\option\paragraph\ItemHTMLParagraph;
use goodsmemo\option\rakuten\RakutenSettingSection;

require_once GOODS_MEMO_DIR . "option/field/FieldInfo.php";
require_once GOODS_MEMO_DIR . "option/paragraph/ItemHTMLParagraph.php";
require_once GOODS_MEMO_DIR . "option/rakuten/RakutenSettingSection.php";

/**
 * Description of ItemHTMLParagraphUtils
 *
 * @author Goods Memo
 */
class ItemHTMLParagraphUtils {

    const DEFAULT_NUMBER_TO_DISPLAY = 1;
    //
    const TITLE_LENGTH_ID = RakutenSettingSection::ID_PREFIX . "_title_length_id";
    const CACHE_EXPIRATION_IN_SECONDS_ID = RakutenSettingSection::ID_PREFIX . "_cache_expiration_in_seconds_id";

    public static function makeFieldInfoArray() {

	$fieldInfoArray = array();

	$titleLengthFieldInfo = new FieldInfo();
	$titleLengthFieldInfo->setFieldID(ItemHTMLParagraphUtils::TITLE_LENGTH_ID);
	$titleLengthFieldInfo->setFieldLabel(ItemHTMLParagraph::DEFAULT_TITLE_LENGTH_LABEL);
	$titleLengthFieldInfo->setDefaultFieldValue(ItemHTMLParagraph::DEFAULT_TITLE_LENGTH_VALUE);
	$titleLengthFieldInfo->setNumericalVerificationEnabled(true);
	array_push($fieldInfoArray, $titleLengthFieldInfo);

	$cacheExpirationInSecondsFieldInfo = new FieldInfo();
	$cacheExpirationInSecondsFieldInfo->setFieldID(ItemHTMLParagraphUtils::CACHE_EXPIRATION_IN_SECONDS_ID);
	$cacheExpirationInSecondsFieldInfo->setFieldLabel(
		ItemHTMLParagraph::DEFAULT_CACHE_EXPIRATION_IN_SECONDS_LABEL);
	$cacheExpirationInSecondsFieldInfo->setDefaultFieldValue(
		ItemHTMLParagraph::DEFAULT_CACHE_EXPIRATION_IN_SECONDS_VALUE);
	$cacheExpirationInSecondsFieldInfo->setNumericalVerificationEnabled(true);
	array_push($fieldInfoArray, $cacheExpirationInSecondsFieldInfo);

	return $fieldInfoArray;
    }

}

PriceParagraphUtils.php

namespace goodsmemo\option\rakuten;

/**
 * Description of PriceParagraphUtils
 *
 * @author Goods Memo
 */
class PriceParagraphUtils {

    const DEFAULT_PRICE_TIME_LINK_VISIBLE = false;
    const DEFAULT_PRICE_TIME_FOOTER_TEXT = "価格の詳細:本商品の購入においては、購入の時点で楽天市場に表示されている価格の情報が適用されます。";

}

RakutenSettingSection.php

楽天の設定画面を表示します。

namespace goodsmemo\option\rakuten;

use goodsmemo\option\AbstractSettingSection;
use goodsmemo\option\PageInfo;
use goodsmemo\option\SettingSection;
use goodsmemo\option\SectionInfo;
use goodsmemo\option\paragraph\URLParagraph;
use goodsmemo\option\paragraph\ItemHTMLParagraph;
use goodsmemo\option\paragraph\ReviewParagraph;
use goodsmemo\option\rakuten\URLParagraphUtils;
use goodsmemo\option\rakuten\CommonRESTParagraph;
use goodsmemo\option\rakuten\CommonRESTParagraphUtils;
use goodsmemo\option\rakuten\ItemHTMLParagraphUtils;
use goodsmemo\option\rakuten\ReviewParagraphUtils;

require_once GOODS_MEMO_DIR . "option/AbstractSettingSection.php";
require_once GOODS_MEMO_DIR . "option/PageInfo.php";
require_once GOODS_MEMO_DIR . "option/SettingSection.php";
require_once GOODS_MEMO_DIR . "option/SectionInfo.php";
require_once GOODS_MEMO_DIR . "option/paragraph/URLParagraph.php";
require_once GOODS_MEMO_DIR . "option/paragraph/ItemHTMLParagraph.php";
require_once GOODS_MEMO_DIR . "option/paragraph/ReviewParagraph.php";
require_once GOODS_MEMO_DIR . "option/rakuten/URLParagraphUtils.php";
require_once GOODS_MEMO_DIR . "option/rakuten/CommonRESTParagraph.php";
require_once GOODS_MEMO_DIR . "option/rakuten/CommonRESTParagraphUtils.php";
require_once GOODS_MEMO_DIR . "option/rakuten/ItemHTMLParagraphUtils.php";
require_once GOODS_MEMO_DIR . "option/rakuten/ReviewParagraphUtils.php";

/**
 * Description of RakutenSettingSection
 *
 * @author Goods Memo
 */
class RakutenSettingSection extends AbstractSettingSection {

    const ID_PREFIX = "rakuten";

    public function initSection(PageInfo $pageInfo) {

	$sectionInfo = new SectionInfo();
	$sectionInfo->setSectionID("rakuten_section_id");
	$sectionInfo->setSectionTitle("楽天の設定");

	add_settings_section(
		$sectionInfo->getSectionID(), // ID
		$sectionInfo->getSectionTitle(), // Title
		array($this, SettingSection::PRINT_SECTION_INFO_FUNCTION_NAME), // Callback
		$pageInfo->getSettingMenuSlug() //設定ページのslug。メニューのslugと同じもの。
	);

	$urlParagraph = new URLParagraph();
	$urlFieldInfoArray = URLParagraphUtils::makeFieldInfoArray();
	$urlParagraph->initParagraph($pageInfo, $sectionInfo, $urlFieldInfoArray);
	parent::addParagraph($urlParagraph);

	$commonRESTParagraph = new CommonRESTParagraph();
	$commonRESTFieldInfoArray = CommonRESTParagraphUtils::makeFieldInfoArray();
	$commonRESTParagraph->initParagraph($pageInfo, $sectionInfo, $commonRESTFieldInfoArray);
	parent::addParagraph($commonRESTParagraph);

	$itemHTMLParagraph = new ItemHTMLParagraph();
	$itemHTMLFieldInfoArray = ItemHTMLParagraphUtils::makeFieldInfoArray();
	$itemHTMLParagraph->initParagraph($pageInfo, $sectionInfo, $itemHTMLFieldInfoArray);
	parent::addParagraph($itemHTMLParagraph);

	$reviewParagraph = new ReviewParagraph();
	$reviewFieldInfoArray = ReviewParagraphUtils::makeFieldInfoArray();
	$reviewParagraph->initParagraph($pageInfo, $sectionInfo, $reviewFieldInfoArray);
	parent::addParagraph($reviewParagraph);
    }

    public function printSectionInfo() {
	print '楽天アフィリエイトの設定を入力してください。未入力の場合、初期値を表示します。';
    }

}

RESTParagraphUtils.php

namespace goodsmemo\option\rakuten;

/**
 * Description of RESTParagraphUtils
 *
 * @author Goods Memo
 */
class RESTParagraphUtils {

    const EXISTENCE_IMAGE_FLAG = 1; //商品画像ありの商品のみを検索対象とする//TODO Choice部品

}

ReviewParagraphUtils.php

namespace goodsmemo\option\rakuten;

use goodsmemo\option\field\FieldInfo;
use goodsmemo\option\paragraph\ReviewParagraph;
use goodsmemo\option\rakuten\RakutenSettingSection;

require_once GOODS_MEMO_DIR . "option/field/FieldInfo.php";
require_once GOODS_MEMO_DIR . "option/paragraph/ReviewParagraph.php";
require_once GOODS_MEMO_DIR . "option/rakuten/RakutenSettingSection.php";

/**
 * Description of ReviewParagraphUtils
 *
 * @author Goods Memo
 */
class ReviewParagraphUtils {

    const EDITORIAL_REVIEW_LENGTH_ID = RakutenSettingSection::ID_PREFIX . "_editorial_review_length_id";
    const ARRAY_OF_STRING_TO_DELETE_ID = RakutenSettingSection::ID_PREFIX . "_array_of_string_to_delete_id";
    const ARRAY_OF_STRING_TO_BREAK_ID = RakutenSettingSection::ID_PREFIX . "_array_of_string_to_break_id";

    public static function makeFieldInfoArray() {

	$fieldInfoArray = array();

	$editorialReviewLengthFieldInfo = new FieldInfo();
	$editorialReviewLengthFieldInfo->setFieldID(ReviewParagraphUtils::EDITORIAL_REVIEW_LENGTH_ID);
	$editorialReviewLengthFieldInfo->setFieldLabel(ReviewParagraph::DEFAULT_EDITORIAL_REVIEW_LENGTH_LABEL);
	$editorialReviewLengthFieldInfo->setDefaultFieldValue(ReviewParagraph::DEFAULT_EDITORIAL_REVIEW_LENGTH_VALUE);
	$editorialReviewLengthFieldInfo->setNumericalVerificationEnabled(true);
	array_push($fieldInfoArray, $editorialReviewLengthFieldInfo);

	$arrayOfStringToDeleteFieldInfo = new FieldInfo();
	$arrayOfStringToDeleteFieldInfo->setFieldID(ReviewParagraphUtils::ARRAY_OF_STRING_TO_DELETE_ID);
	$arrayOfStringToDeleteFieldInfo->setFieldLabel(ReviewParagraph::DEFAULT_ARRAY_OF_STRING_TO_DELETE_LABEL);
	$arrayOfStringToDeleteFieldInfo->setDefaultFieldValue(ReviewParagraph::DEFAULT_ARRAY_OF_STRING_TO_DELETE_VALUE);
	array_push($fieldInfoArray, $arrayOfStringToDeleteFieldInfo);

	$arrayOfStringToBreakFieldInfo = new FieldInfo();
	$arrayOfStringToBreakFieldInfo->setFieldID(ReviewParagraphUtils::ARRAY_OF_STRING_TO_BREAK_ID);
	$arrayOfStringToBreakFieldInfo->setFieldLabel(ReviewParagraph::DEFAULT_ARRAY_OF_STRING_TO_BREAK_LABEL);
	$arrayOfStringToBreakFieldInfo->setDefaultFieldValue(ReviewParagraph::DEFAULT_ARRAY_OF_STRING_TO_BREAK_VALUE);
	array_push($fieldInfoArray, $arrayOfStringToBreakFieldInfo);

	return $fieldInfoArray;
    }

}

SearchParagraphUtils.php

namespace goodsmemo\option\rakuten;

/**
 * Description of SearchParagraphUtils
 *
 * @author Goods Memo
 */
class SearchParagraphUtils {

    const ICHIBA_ITEM_SEARCH_OPERATION = "IchibaItem"; //TODO Choice部品

}

URLParagraphUtils.php

namespace goodsmemo\option\rakuten;

use goodsmemo\option\field\FieldInfo;
use goodsmemo\option\rakuten\RakutenSettingSection;

require_once GOODS_MEMO_DIR . "option/field/FieldInfo.php";
require_once GOODS_MEMO_DIR . "option/rakuten/RakutenSettingSection.php";

/**
 * Description of URLFieldUtils
 *
 * @author Goods Memo
 */
class URLParagraphUtils {

    const HOSTNAME_ID = RakutenSettingSection::ID_PREFIX . "_hostname_id";
    const PATH_ID = RakutenSettingSection::ID_PREFIX . "_path_id";

    public static function makeFieldInfoArray() {

	$fieldInfoArray = array();

	$hostnameFieldInfo = new FieldInfo();
	$hostnameFieldInfo->setFieldID(URLParagraphUtils::HOSTNAME_ID);
	$hostnameFieldInfo->setFieldLabel('楽天商品検索API ホスト名');
	$hostnameFieldInfo->setDefaultFieldValue("app.rakuten.co.jp");
	array_push($fieldInfoArray, $hostnameFieldInfo);

	$pathFieldInfo = new FieldInfo();
	$pathFieldInfo->setFieldID(URLParagraphUtils::PATH_ID);
	$pathFieldInfo->setFieldLabel('楽天商品検索API リクエストURLのパス');
	$pathFieldInfo->setDefaultFieldValue("services/api/IchibaItem/Search/20170706");
	array_push($fieldInfoArray, $pathFieldInfo);

	return $fieldInfoArray;
    }

}
コンピューター
この記事をシェアする

【広告】WordPress 開発 」の関連商品

• Amazon.co.jp

エンジニアのためのWordPress開発入門 (Engineer's Library)

エンジニアのためのWordPress開発入門 (Engineer's Library)

Amazon 価格:3,218 円(2019年5月25日 10:25時点詳細はこちら)

著者:野島 祐慈, 菱川 拓郎, 杉田 知至, 細谷 崇, 枢木 くっくる

出版社:技術評論社

種別:単行本(ソフトカバー)

販売店:Amazon.co.jp

サイトの拡張性を飛躍的に高める WordPressプラグイン開発のバイブル

サイトの拡張性を飛躍的に高める WordPressプラグイン開発のバイブル

著者:宮内 隆行, 西川 伸一, 岡本 渉, 三好 隆之

出版社:SBクリエイティブ

種別:Kindle版

プラグインの開発から運用までを網羅※この電子書籍は、「固定レイアウト型」で配信されております。説明文の最後の「固定レイアウト型に関する注意事項」を必ずお読みください。CMSのデファクト・スタンダードである……

• 楽天市場

エンジニアのためのWordPress開発入門【電子書籍】[ 野島祐慈 ]

エンジニアのためのWordPress開発入門【電子書籍】[ 野島祐慈 ]

価格:3,218 円[税込](2019年5月25日 10:25時点)
送料込

販売店:楽天Kobo電子書籍ストア

【電子書籍なら、スマホ・パソコンの無料アプリで今すぐ読める!】
WordPressを使った開発案件は依然多く,それに携わるWebエンジニアも多数存在します。ただし,モダンな開発手法に慣れたWebエンジニアがWordP……

WordPress Web開発逆引きレシピ WordPress 4.x/PHP 7対応 プロが選んだ三ツ星レシピ ……

WordPress Web開発逆引きレシピ WordPress 4.x/PHP 7対応 プロが選んだ三ツ星レシピ ……

価格:3,024 円[税込](2019年5月25日 10:25時点)
送料込

ポイント:2 倍
✓開始日時2019-05-23 10:00
✓終了日時2019-05-27 09:59

販売店:楽天ブックス

【楽天ブックスならいつでも送料無料】
プロが選んだ三ツ星レシピ Programmer’s recipe 藤本壱 翔泳社ワードプレスウェブカイハツギャクビキレシピ ワードプレスヨンテンアックス ピーエイチピーセブンタイオ……

グッズ・メモランダム