from django.template.loader import render_to_string from django.utils.importlib import import_module from pressgang.actions.options import Option, Options from pressgang.utils.registry import create_registry import os BlogOptionRegistry = create_registry('id') class BlogOption(Option): """Base class for a single blog option.""" __metaclass__ = BlogOptionRegistry # The path to the blog-options template directory _BLOG_OPTIONS_TEMPLATE_DIR = "pressgang/options/blog" # The name of the template file used to render the plugin, relative to the # root blog-options template directory template = None def generate_code(self, blog, value): """Add code for a plugin to apply the WordPress option. Arguments: blog -- an instance of a Blog object value -- the value of the option as a Python data type Returns: PHP code to apply the option
from django.template.loader import render_to_string from django.utils.importlib import import_module from pressgang.actions.options import Option, Options from pressgang.utils.registry import create_registry SiteOptionRegistry = create_registry('id') class SiteOption(Option): """Base class for a single site option.""" __metaclass__ = SiteOptionRegistry # The databse ID used by WordPress for the site option wp_id = None # A custom template to use to set the option, relative to the site-options # template directory template = None # Whether the option is only available on multisite installations multisite_only = False def generate_code(self, blog, value): """Add code for a plugin to apply the WordPress option. Arguments: blog -- an instance of a Blog object value -- the value of the option as a Python data type