nd the author name.', 'wprss'), 'date_enabled' => __('Enable this to show the feed item\'s date.', 'wprss'), 'date_prefix' => __('Enter the text that you want to show before the feed item date. A space is automatically added between this text and the date.', 'wprss'), 'date_format' => __('The format to use for the feed item dates, as a PHP date format.', 'wprss'), 'date_use_time_ago' => __('Enable this option to show the elapsed time from the feed item\'s date and time to the present time. Eg. 2 hours ago', 'wprss'), 'links_behavior' => __('Choose how you want links to be opened. This applies to the feed item title and the source link.', 'wprss'), 'links_nofollow' => __('Enable this option to set all links displayed as "NoFollow".
"Nofollow" provides a way to tell search engines to not follow certain links, such as links to feed items in this case.', 'wprss'), 'link_to_embed' => __('Tick this box to have feed items link to their embedded content, if they have any. This works especially well when links are set to "Open in a lightbox".', 'wprss'), 'bullets_enabled' => __('Enable this option to show bullets next to feed items.', 'wprss'), 'bullet_type' => __('The bullet type to use for feed items.', 'wprss'), 'custom_css_classname' => __('You can add your own HTML class name to the template output. This lets you customize your template further using custom CSS styling or custom JS functionality.'), 'audio_player_enabled' => __('If the feed item or post has an audio attachment, you can choose to show an audio player that plays the attached audio file.'), ], ]; }, /* * Feed template's types options. * * @since 4.13.2 */ 'wpra/feeds/templates/template_types_options' => function (ContainerInterface $c) { // The built in type, which appears as "List" $types = [ '__built_in' => __('List', 'wprss'), ]; // Add all other template types foreach ($c->get('wpra/feeds/templates/template_types') as $key => $templateType) { $types[$key] = $templateType->getName(); } return $types; }, /* * Whether template type selection is available or not. * * @since 4.13.2 */ 'wpra/feeds/templates/template_type_enabled' => function (ContainerInterface $c) { return false; }, /* * Feed template's fields options. * * @since 4.13 */ 'wpra/feeds/templates/template_options' => function (ContainerInterface $c) { return [ 'is_type_enabled' => $c->get('wpra/feeds/templates/template_type_enabled'), 'type' => $c->get('wpra/feeds/templates/template_types_options'), 'links_behavior' => [ 'self' => __('Open in same tab/window', 'wprss'), 'blank' => __('Open in a new tab', 'wprss'), 'lightbox' => __('Open in a lightbox', 'wprss'), ], 'pagination_type' => [ 'default' => __('Older/Newer', 'wprss'), 'numbered' => __('Numbered', 'wprss'), ], 'bullet_type' => [ 'default' => __('Bullets', 'wprss'), 'numbers' => __('Numbers', 'wprss'), ], 'links_video_embed_page' => [ 'false' => __('Original page link', 'wprss'), 'true' => __('Embedded video player link', 'wprss'), ], ]; }, /* * The list of JS modules to load. * * @since 4.13.2 */ 'wpra/feeds/templates/admin/js_modules' => function (ContainerInterface $c) { return [ 'templates-app', ]; }, /* * The assets used on the admin templates page. * * @since 4.14 */ 'wpra/feeds/templates/admin/assets' => function (ContainerInterface $c) { return [ $c->get('wpra/feeds/templates/admin/styles/main'), $c->get('wpra/feeds/templates/admin/scripts/main'), ]; }, /* * The template style. * * @since 4.14 */ 'wpra/feeds/templates/admin/styles/main' => function () { return new StyleAsset('wpra-templates', WPRSS_APP_CSS . 'templates.min.css', ['wpra-common']); }, /* * The template script. * * @since 4.14 */ 'wpra/feeds/templates/admin/scripts/main' => function (ContainerInterface $c) { $script = new ScriptAsset('wpra-templates', WPRSS_APP_JS . 'templates.min.js', [ 'wpra-manifest', 'wpra-vendor', ]); $script = $script->localize('WpraTemplates', function () use ($c) { return $c->get('wpra/feeds/templates/admin/states/main'); }); $script = $script->localize('WpraGlobal', function () use ($c) { return $c->get('wpra/feeds/templates/admin/states/global'); }); return $script; }, /* * Whether audio features are enabled. * * @since 4.18 */ 'wpra/feeds/templates/audio_features_enabled' => function () { return false; }, /* * The state for the templates script. * * @since 4.14 */ 'wpra/feeds/templates/admin/states/main' => function (ContainerInterface $c) { return [ 'model_schema' => $c->get('wpra/feeds/templates/model_schema'), 'model_tooltips' => $c->get('wpra/feeds/templates/model_tooltips'), 'options' => $c->get('wpra/feeds/templates/template_options'), 'modules' => $c->get('wpra/feeds/templates/admin/js_modules'), 'base_url' => rest_url('/wpra/v1/templates'), 'audio_features_enabled' => $c->get('wpra/feeds/templates/audio_features_enabled'), ]; }, /* * The global state of the application. * * @since 4.14 */ 'wpra/feeds/templates/admin/states/global' => function (ContainerInterface $c) { $siteUrl = rtrim(site_url(), '/'); $templatesUrl = menu_page_url('wpra_feed_templates', false); return [ 'admin_base_url' => admin_url(), 'templates_url_base' => str_replace($siteUrl, '', $templatesUrl), 'is_existing_user' => !wprss_is_new_user(), 'nonce' => wp_create_nonce('wp_rest'), ]; }, /* * The handler that renders the admin templates page. * * @since 4.14 */ 'wpra/feeds/templates/admin/render_handler' => function (ContainerInterface $c) { return new RenderAdminTemplatesPageHandler($c->get('wpra/feeds/templates/admin/assets')); }, /* * The handler that renders template content. * * @since 4.13 */ 'wpra/feeds/templates/handlers/render_content' => function (ContainerInterface $c) { return new RenderTemplateContentHandler( $c->get('wpra/feeds/templates/cpt/name'), $c->get('wpra/feeds/templates/master_template'), $c->get('wpra/feeds/templates/generic_template'), $c->get('wpra/feeds/templates/collection') ); }, /* * The handler that hides template content from the public-facing side. * * @since 4.13 */ 'wpra/feeds/templates/handlers/hide_public_content' => function (ContainerInterface $c) { return new HidePublicTemplateContentHandler( $c->get('wpra/feeds/templates/cpt/name'), $c->get('wpra/feeds/templates/public_template_content_nonce') ); }, /* * The name of the nonce that allows template content to be shown on the public-facing side. * * @since 4.13 */ 'wpra/feeds/templates/public_template_content_nonce' => function (ContainerInterface $c) { return 'wpra_template_preview'; }, /* * The handler that listens to requests for previewing templates. * * @since 4.13 */ 'wpra/feeds/templates/handlers/preview_template_request' => function (ContainerInterface $c) { return new PreviewTemplateRedirectHandler( $c->get('wpra/feeds/templates/preview_template_request_param'), $c->get('wpra/feeds/templates/public_template_content_nonce'), $c->get('wpra/feeds/templates/cpt/capability') ); }, /* * The name of the GET parameter to detect for previewing templates. * * @since 4.13 */ 'wpra/feeds/templates/preview_template_request_param' => function (ContainerInterface $c) { return 'wpra_preview_template'; }, /* * The handler that synchronizes the default template with the display settings. * * @since 4.13 */ 'wpra/feeds/templates/handlers/sync_default_template' => function (ContainerInterface $c) { return new ReSaveTemplateHandler( $c->get('wpra/feeds/templates/collection'), $c->get('wpra/feeds/templates/default_template_data') ); }, /* * The templates GET endpoint for the REST API. * * @since 4.13 */ 'wpra/feeds/templates/rest_api/v1/get_endpoint' => function (ContainerInterface $c) { return new GetTemplatesEndPoint($c->get('wpra/feeds/templates/collection')); }, /* * The templates PATCH endpoint for the REST API. * * @since 4.13 */ 'wpra/feeds/templates/rest_api/v1/patch_endpoint' => function (ContainerInterface $c) { return new PatchTemplateEndPoint($c->get('wpra/feeds/templates/collection')); }, /* * The templates POST endpoint for the REST API. * * @since 4.13 */ 'wpra/feeds/templates/rest_api/v1/post_endpoint' => function (ContainerInterface $c) { return new CreateUpdateTemplateEndPoint($c->get('wpra/feeds/templates/collection'), false); }, /* * The templates PUT endpoint for the REST API. * * @since 4.13 */ 'wpra/feeds/templates/rest_api/v1/put_endpoint' => function (ContainerInterface $c) { return new CreateUpdateTemplateEndPoint($c->get('wpra/feeds/templates/collection')); }, /* * The templates deletion endpoint for the REST API. * * @since 4.13 */ 'wpra/feeds/templates/rest_api/v1/delete_endpoint' => function (ContainerInterface $c) { return new DeleteTemplateEndPoint($c->get('wpra/feeds/templates/collection')); }, /* * The templates rendering endpoint for the REST API. * * @since 4.13 */ 'wpra/feeds/templates/rest_api/v1/render_endpoint' => function (ContainerInterface $c) { return new RenderTemplateEndPoint( $c->get('wpra/display/feeds/template'), $c->get('wpra/feeds/templates/generic_template') ); }, ]; } /** * {@inheritdoc} * * @since 4.13 */ public function getExtensions() { return [ /* * Register the templates UI assets for the admin-side. * * @since 4.14 */ 'wpra/assets/admin' => function(ContainerInterface $c, $assets) { foreach ($c->get('wpra/feeds/templates/admin/assets') as $asset) { $assets[] = $asset; } return $assets; }, /* * Overrides the core display template with the master template. * * @since 4.13 */ 'wpra/display/feeds/template' => function (ContainerInterface $c) { return $c->get('wpra/feeds/templates/master_template'); }, /* * Extends the list of REST API endpoints with the template endpoints. * * @since 4.13 */ 'wpra/rest_api/v1/endpoints' => function (ContainerInterface $c, $endPoints) { $endPoints['get_templates'] = new EndPoint( '/templates(?:/(?P[^/]+))?', ['GET'], $c->get('wpra/feeds/templates/rest_api/v1/get_endpoint'), null //$c->get('wpra/rest_api/v1/auth/user_is_admin') ); $endPoints['patch_templates'] = new EndPoint( '/templates/(?P[^/]+)', ['PATCH'], $c->get('wpra/feeds/templates/rest_api/v1/patch_endpoint'), $c->get('wpra/rest_api/v1/auth/user_is_admin') ); $endPoints['put_templates'] = new EndPoint( '/templates(?:/(?P[^/]+))?', ['PUT'], $c->get('wpra/feeds/templates/rest_api/v1/put_endpoint'), $c->get('wpra/rest_api/v1/auth/user_is_admin') ); $endPoints['post_templates'] = new EndPoint( '/templates(?:/(?P[^/]+))?', ['POST'], $c->get('wpra/feeds/templates/rest_api/v1/post_endpoint'), $c->get('wpra/rest_api/v1/auth/user_is_admin') ); $endPoints['delete_templates'] = new EndPoint( '/templates(?:/(?P[^/]+))?', ['DELETE'], $c->get('wpra/feeds/templates/rest_api/v1/delete_endpoint'), $c->get('wpra/rest_api/v1/auth/user_is_admin') ); $endPoints['render_templates'] = new EndPoint( '/templates/(?P